Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-57478

Switching window flags destroys window hierarchy

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 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
    • Fix Version/s: None
    • Component/s: GUI: Window management
    • Labels:
      None
    • Environment:
      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();
      }
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              chrisaverage Krzysztof Kawa
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes