Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Instantiator Active Bug
Qt 6.11 is out! See what's new in the release blog

Instantiator Active Bug

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 704 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1

    If active is false, and I modify the ListModel dynamically, then the Instantiator will create "some" objects. I have found if there were ListElements defined first, then each insert into the ListModel would cause the Instantiator to create those first. Either way, it shouldn't be creating anything.

    I was trying to reproduce the code where the bug started. That is why there is a StackView and Page. Probably not related to the issue.

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.15
    import QtQml.Models 2.15
    
    Window {
        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
                }
            }
        }
    }
    

    I think I have to figure out how to use just one Instantiator in my code. I will submit a bug report, but people might be interested in this so I am posting here. I tried multiple versions of import QtQml.Models and it didn't have an effect.

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Bug Report

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved