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

Regression: When a Menu is used with a Repeater and a ListModel, the MenuItems overlap

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 6.5.5
    • Quick: Controls 2
    • None
    • Windows

    Description

      This seems to be related to QTBUG-104470 and QTBUG-104544.

      With the following code, we get a similar result to what QTBUG-104470 describes.

      Tagging chen_bin  to get input on this since the regression seems to be related to QTBUG-104544.

       

      import QtQuick
      import QtQuick.Window
      import QtQuick.Controls
      
      Window {
          width: 640
          height: 480
          visible: true
      
          Row {
              spacing: 10
      
              Button {
                  text: "Options Menu"
                  onClicked: {
                      generateItems()
                      const cmp = repButton.checked ? cmpRepeater : cmpInstantiator
                      const obj = cmp.createObject(this, {"x":x + width,"y": y + height,"model": menuModel})
                      obj.onClosed.connect(function() {
                          obj.destroy();
                      });
                      obj.open()
                  }
              }
      
              ButtonGroup {
                  buttons: column.children
                  exclusive: true
              }
      
              Column {
                  id: column
      
                  RadioButton {
                      id: repButton
                      checked: true
                      text: qsTr("Repeater")
                  }
      
                  RadioButton {
                      text: qsTr("Instantiator")
                  }
              }
      
          }
      
          Component {
              id: cmpRepeater
      
              Menu {
                  id: menu
      
                  property alias model: repeater.model
      
                  height: 240
      
                  Repeater {
                      id: repeater
                      delegate: MenuItem {
                          text: name
                          onClicked: {
                              menu.close()
                          }
                      }
                  }
              }
          }
      
          Component {
              id: cmpInstantiator
      
              Menu {
                  id: menu
      
                  property alias model: instantiator.model
      
                  height: 240
      
                  Instantiator {
                      id: instantiator
                      onObjectAdded: (index, object) => {
                          menu.addItem(object)
                      }
                      onObjectRemoved: (index, object) => {
                          menu.removeItem(object)
                      }
                      delegate: MenuItem {
                          text: name
                          onClicked: {
                              menu.close()
                          }
                      }
                  }
              }
          }
      
          ListModel {
              id: menuModel
          }
      
          function generateItems() {
              menuModel.clear();
              for (var i = 1; i <= 21; ++i) {
                  menuModel.append({"name": Math.random() * i});
              }
          }
      }
      

      Attachments

        Issue Links

          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
              uzumcuf Furkan Uzumcu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes