QDialog always on top if parented on QMainWindow
-
wrote on 30 Jul 2015, 13:42 last edited by
I've noticed that the QDialogs in my application always stay on top of the main window if they are parented on it. As soon as I don't provide any parent, they can again be stacked independently. Unforunately I now lose the connection between the two widgets, especially that the child widget is always spawned centered inside the parent. Can I somehow combine the two behaviors?
-
wrote on 30 Jul 2015, 14:38 last edited by
Hi, I'm not exactly sure what you want to do here, but if you want to remove the "stay on top" behaviour you should change the window flags of your dialog (if it can be done) : http://doc.qt.io/qt-5/qwidget.html#windowFlags-prop, http://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html.
I hope that helps.
-
wrote on 31 Jul 2015, 14:55 last edited by
This won't help as the always on top window flag isn't set by default. It appears as though the described behavior is the intended Qt standard once you set a parent on widgets.
-
wrote on 2 Aug 2015, 05:31 last edited by
Yes my bad, I pointed you to the wrong property. Actually you must set the windowModality property : http://doc.qt.io/qt-5/qwidget.html#windowModality-prop, or the modal prop (only for QDialogs) : http://doc.qt.io/qt-5/qdialog.html#modal-prop. I believe that is the solution you've been looking for.
4/4