[Qt-qml] Set custom property in onChildrenChanged?

aaron.kennedy at nokia.com aaron.kennedy at nokia.com
Tue Oct 26 14:59:53 CEST 2010


Hi,

Shouldn't the access line read

    myParent.children[i].myDouble = 1.0

?

Cheers,

Aaron
________________________________________
From: qt-qml-bounces at trolltech.com [qt-qml-bounces at trolltech.com] on behalf of ext Charley Bay [charleyb123 at gmail.com]
Sent: Tuesday, October 26, 2010 10:49 PM
To: qt-qml at trolltech.com
Subject: [Qt-qml] Set custom property in onChildrenChanged?

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
_______________________________________________
Qt-qml mailing list
Qt-qml at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml




More information about the Qt-qml mailing list