[Qt-qml] Set custom property in onChildrenChanged?
Charley Bay
charleyb123 at gmail.com
Tue Oct 26 14:49:58 CEST 2010
Curious problem, this should work, right?
//FILE: MyRect.qml
Rectangle {
property double myDouble: 0
}
//FILE: MyParent.qml
Item {
id: myParent
onChildrenChanged: {
for(var i = 0; i < myParent.children.length; ++i) {
// Error: Cannot assign to non-existent property "myDouble"
myParent.children.[i].myDouble = 1.0
}
}
}
MyRect {
parent: myParent
}
Everything instantiates properly, and "MyRect" is properly
being parented under "MyParent", with "onChildrenChanged"
being called.
Can I not access the custom property? Do I need to cast
to a "MyRect" inside "onChildrenChanged"?
In this case, I *always* know it is a "MyRect", but I thought
the dynamic typing would have found the "myDouble"
property.
Should this code work? (Or what should I do instead?)
Thanks!
--charley
More information about the Qt-qml
mailing list