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

QML Menu does not allow its subMenu to popup at different position in certain circumstances

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 6.5.2
    • Quick: Controls 2
    • None

    Description

      I found that QML Menu popup API is not working as expected if the Menu is a subMenu of another Menu in some circumstances. Minimal Reproducer:

      ApplicationWindow {
          id: window
      
          menuBar: MenuBar {
              Menu {
                  title: qsTr("&Edit")
                  Menu {
                      title: qsTr("&Help")
                      Action {
                          text: qsTr("&About")
                      }
                      Action {
                          text: qsTr("&Copy")
                      }
                      Action {
                          text: qsTr("&Paste")
                      }
                  }
                  Action {
                      text: qsTr("Cu&t")
                  }
                  delegate: MenuItem {
                      onHoveredChanged: {
                          if (hovered && subMenu) {
                              subMenu.popup(this, 0, 500);
                          }
                      }
                  }
              }
          }
      
          width: 400
          height: 300
          visible: true
      }
      

      No matter how I modify "subMenu.popup(this, 0, 500);", e.g. positive/negative coordinates, binding to other geometries, mapfromglobal/maptoglobal, assigning different parents, etc., it makes no difference. subMenu "Help" always pops at the same position, i.e. visually aligned to the MenuItem.

      The only way I found so far is to have an Item positioned w.r.t ApplicationWindow and use it as parent to subMenu.popup. But ding so makes it very difficult to position subMenu w.r.t parent menu.

      Attachments

        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
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes