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

QMdiSubWindow resets parent of its base widget in removeSubWindow()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 4.8.7, 5.4.2, 5.5.0
    • Widgets: Main Window
    • None
    • 63949183f04ee953198e6544912404701151a98b

      Our Qt application with customised UI allows user to rearrange content widgets as tabbed, standalone MDI, etc. For example, user can drag'n'drop some content widget from MDI window to Tabbet Window, so we execute code like this:

      mdiArea->removeSubWindow(baseWidget);
      baseWidget->setParent(tabbedWindow);
      

      But removeSubWindow calls baseWidget->setParent(0) also, so parent of our widget is changed twice. Note that setParent(0) turns our widget as top-level window, so there are a lot of side effects with geometry, layouts, so on.
      We can avoid those bugs to change our code:

      baseWidget->setParent(tabbedWindow);
      mdiArea->removeSubWindow(baseWidget);
      

      and exclude setParent(0) from removeSubWindow() if parent of base widget is already changed.

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

            mmutz Marc Mutz
            lserge Serge Lysenko
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes