Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.6.2, 5.7.1, 5.8.0, 5.9.0, 5.10.0, 5.11.0, 5.11.1, 5.11.2, 5.11.3, 5.12.0, 5.13.1
-
None
-
Windows 10
Description
Switching window flags (e.g. to make a widget a window) makes its children possible to hide under it.
Example: 3 widgets: parent -> child ->grandchild. Parent is a window. Child is not a window. Grandchild is a window and should not be able to hide under child or parent. Change child flags to make it a window and now grandchild can be hidden under child.
A workaround is to re-parent the grandchild after child flags changed but in a large app with many windows this is not easily manageable.
Example code:
#include <QApplication> #include <QWidget> int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget parent; parent.setWindowTitle("Parent"); parent.show(); QWidget* child = new QWidget(&parent); child->setWindowTitle("Child"); QWidget* grandchild = new QWidget(child, Qt::Dialog); grandchild->setWindowTitle("Grandchild"); grandchild->show(); //this breaks hierarchy child->setWindowFlags(Qt::Dialog); child->show(); //uncomment for a workaround //Qt::WindowFlags flags = child->windowFlags(); //grandchild->setParent(nullptr); //grandchild->setParent(child, flags); //grandchild->show(); return a.exec(); }