QDialog always on top if parented on QMainWindow
-
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?
-
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.
-
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.
-
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.