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

QWidget in QSplitter reporting wrong position after reparenting

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12.7
    • None
    • Windows

    Description

      We have window system where a main widget holds a view widget which can be split by pressing a button. When this is done two new main widgets are created in each side of a QSplitter, the initial view is parented to one of the new widgets and a new view added to the other, and the QSplitter parented to the main widget.

      Part of the view widget is a button which pops up a menu. The menu position is based on the global position of the button, such that it appears just below it. In the initial view, this works fine. After the view has been split, the menu appears correctly only for the right-hand view; for the left-hand view, the menu is offset by the global position of the button. This continues as more views are split - the last view is always correct, but the others have increasing offsets.

      This issue seems to resolve itself if the widgets are added to the QSplitter before the QSplitter is added to the layout of the main widget.

      See attached example. Click the "Menu" button - menu appears just below the button. Click "Split". Press the right-hand "Menu" button - menu appears just below the button. Press the left-hand "Menu" button - menu appears offset. Split again, repeat - menus are progressively further from the correct position.

      Moving line TestWidget.cpp:59 to TestWidget.cpp:62 fixes the issue.

      Attachments

        1. MenuBad.png
          MenuBad.png
          21 kB
        2. MenuGood.png
          MenuGood.png
          16 kB
        3. QMenuGlobalPosTest2.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            stevemalton Stephen Malton
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes