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

Wrong order after changing model of Repeater inside Menu

    XMLWordPrintable

Details

    Description

      I have a menu with some static and some dynamic items. The dynamic ones are instantiated using a Repeater. After changing the model, the items instantiated by the Repeater are inserted at the end of the menu. Expected is that they are inserted at the position of the repeater.

      To reproduce, try the code example below:

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      import QtQuick.Layouts 1.3
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          header: ToolBar {
              id: toolBar
      
              Row {
                  id: buttons
                  ToolButton {
                      id: menuButton
                      onClicked: menu.open()
                      text: "open"
                  }
      
                  ToolButton {
                      id: showButton
                      checkable: true
                      text: checked ? "hide" : "show"
                  }
              }
          }
      
          Menu {
              id: menu
      
              MenuItem {
                  text: "Begin"
              }
      
              Repeater {
                  id: repeater
                  model: showButton.checked ? 4 : 2
                  delegate: MenuItem {
                      text: index
                  }
              }
      
              MenuItem {
                  text: "End"
              }
          }
      }
      

       

      1. Click open to open the menu. The menu items should have the following correct order:
        • Begin
        • 0
        • 1
        • End
      2. Click the button "show" and open the menu again.
        • Expectation:
          • Begin
          • 0
          • 1
          • 2
          • 3
          • End
        • Result:
          • Begin
          • End
          • 0
          • 1
          • 2
          • 3

      Attachments

        Activity

          People

            mitch_curtis Mitch Curtis
            hessi Markus Heß
            Votes:
            4 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: