PDA

View Full Version : dynamic object id



jovin
29th April 2012, 23:47
Hello,


Repeater {
model: 10

MyWindow {
id: "mywindownumber" + index
x: 20 + index * 30
y: 200
}
}


It's obviously not working, but is there a way to achieve something similar?

hurmatt
30th April 2012, 05:17
Maybe it's possible to use dynamically created components, which you can refer to by the Javascript variable but only within a function (http://qt-project.org/doc/qt-4.8/qdeclarativedynamicobjects.html). I use this method for creating and destroying dynamic components.

You can also create a component from a QML file (http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedocuments.html) but I don't know if you can assign the id after it's created.

Le_B
1st May 2012, 02:19
there s an itemAt(index) method