PDA

View Full Version : Iterating through Items put within a QML Column element



chinmay_s
29th December 2010, 13:14
I have a QML application with several Rectangle Elements put within a Column Element.
Is there any way i can Iterate through these Column using some index .. so that i can change property of a particular rectangle within the the Column .

grisson
16th September 2011, 12:11
up on this post because i'm interested.
Iterating over (and if is possible, delete) dynamically created elements (with createObject) in QML column.

kornicameister
17th September 2011, 22:48
Would not be sufficient just to create objects inside JavaScript, like mentioned in Qt docs, store them, for example in an array, and than call destroy() method on the objects, that are no longer needed ? To be precise objects' parent should be the column element, which would placed them inside of it...

grisson
19th September 2011, 21:48
I've tried with an array but for some reason is not useful for my purpose. But i've found a solution that works fine form me.
Every time that a new object is created with createObject i do this:

var obj = [].createobject();
obj.variousData=someVariusDataPassed;
obj.objectName: "dynObject_"+identificator

and from c++ now is simple find and use the created object via his objectName.
The identificator is a number passed from c++ when it call the function containing the previous code.

jpn
19th September 2011, 21:53
I have a QML application with several Rectangle Elements put within a Column Element.
Is there any way i can Iterate through these Column using some index .. so that i can change property of a particular rectangle within the the Column .
Yes, you can iterate children, for example:


for (var i = 0; i < column.children.length; ++i)
column.children[i].width = column.width;