[Qt-qml] Component and createObject
Dominic Genest
dom at biocad.ca
Wed Apr 21 12:41:56 CEST 2010
Hi,
I think I misunderstand something about dynamic object creation. In my
code here, "rond.createObject()" doesn't do anything. I guess this
method is not indended to be used that way. Is there a way to
dynamically create an object from a component which is specified in a
"Component{...}" block in the same file?
Thanks; regards,
Dom
import Qt 4.7;
Rectangle
{
width:200; height:200;
Component
{
id: "rond";
Rectangle
{
id: "allo"; x: 30; y: 40; width: 3; height: 3; color: "blue";
Timer
{
interval: 50; running: true; repeat: true;
onTriggered: { if(allo.x++>80) allo.destroy(); }
}
}
}
Timer
{
interval: 500; running: true; repeat: true;
onTriggered: { rond.createObject(); }
}
Loader { sourceComponent: rond; }
}
More information about the Qt-qml
mailing list