Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
5.9.3
-
None
-
Windows 10
Description
In the following example, dialog 'Foo' is being drawn under its parent, the window is modal, active and eats user input, yet it is drawn under 'Bar'.
Note that this only happens these two dialogs are first opened in child-parent relationship and then the relationship is reversed.
#include <QApplication> #include <QDialog> int main(int argc, char *argv[]) { QApplication a(argc, argv); QDialog mainDialog; mainDialog.setWindowTitle("mainDialog"); mainDialog.resize(500, 500); QDialog bar(&mainDialog); bar.setWindowTitle("bar"); bar.resize(400, 300); QDialog foo(&mainDialog); foo.setWindowTitle("foo"); foo.resize(300, 400); mainDialog.open(); // parent one dialog to another and open them foo.open(); bar.setParent(&foo, bar.windowFlags()); bar.open(); // close dialogs bar.reject(); foo.reject(); // re-order parent-child and open again bar.setParent(&mainDialog, bar.windowFlags()); bar.open(); foo.setParent(&bar, foo.windowFlags()); foo.open(); return a.exec(); }
Changing the line:
bar.setParent(&mainDialog, bar.windowFlags());
to
auto flags = bar.windowFlags(); bar.setParent(&mainDialog); bar.setWindowFlags(flags);
seems to solve the issue, but it causes another bug - https://bugreports.qt.io/browse/QTBUG-70240