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

    • Linux/Wayland
    • a1c1ad11ce6f4a415cefc583cfab41336ecf71e3 (qt/qtdeclarative/dev) e51f6cd8af19d1c55faae39e0e1c0203b619fb19 (qt/qtdeclarative/6.2) e25c25453c (qt/tqtc-qtdeclarative/5.15)

    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

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes