Too often called createObject
Solved
QML and Qt Quick
-
Rectangle { id: rect1 color: Material.backgroundColor .... ListView { id: listView model: myModel delegate: Rectangle { Row { ... Component { id: componentText Text { id: nameLink text: qsTr("Hello World!") } } Column { id: column resources: { for(var i=0; i<modelPath.length; i++) { var path = modelPath[i] componentText.createObject(column, {"text": "path name: '" + path }) } } } } } } } } } }
If I run the code the first time column has the same number of items as the number of modelPath.length. After a switch was pressed the color changed. Hence the above code is running again and after that my column component has twice as many number of items as the number of modelPath.length.
The information of the switch comes from another .qml-file.
Is it possible that the column component are create once? -
Don't use createObject.
Column { Repeater { model: modelPath Text { text: "path name: " + modelData } } }
-
@KaNe09 said in Too often called createObject:
With Repeater I got a column with modelPath entries and each entry has all my paths. I want a column with each line has one path
That's what the code I pasted does, equivalent to what your imperative code did.
It creates a Text for each path of your modelPath