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

Instantiator creates delegates when active is false if items are dynamically added to a ListModel

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/Wayland

      Description

      Instantiator creates delegates when active property is false if items are dynamically added to a ListModel associated with the Instantiator.

      It won't let me attached the zip file (Jira token error) of the project so I am pasting the main.qml:

      // code
      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.15
      import QtQml.Models 2.15Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Instantiator Active Bug")    ListModel {
              id: listmodel        dynamicRoles: true        /*
              ListElement{name:"not one"}
              ListElement{name:"not two"}
              ListElement{name:"not three"}
              */
          }    Component.onCompleted: {
              if(1){
                  listmodel.insert(listmodel.count, {name: "one"})
                  listmodel.insert(listmodel.count, {name: "two"})
                  listmodel.insert(listmodel.count, {name: "three"})
              }
          }    StackView {
              anchors.fill: parent        initialItem: page1
          }    Component {
              id: page1        Page {
                  Instantiator {
                      id: instantiator                // https://doc.qt.io/qt-5/qml-qtqml-models-instantiator.html#active-prop
                      active: false                model: listmodel                delegate: Text {
                          width: 100
                          height: 20                    text: name                    Component.onCompleted: console.log(instantiator.active, name)
                      }                onObjectAdded: column.data.push(object)                onActiveChanged: console.log(active)
                  }            Column {
                      id: column
                  }
              }
          }
      }
      
      

       

       

        Attachments

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

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            fcarney Frank Carney
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes