Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.7.0
-
aa40f956bab22678b62f630af97f51f9e8fab9f8, ed742d3c46eca7584b6fcb20c2de941852613fb2
Description
At the moment, bindings for dynamically created objects are evaluated immediately. This produces binding errors ("cannot assign [undefined] to X", etc.) if the created object has properties with bindings, as the property values have not yet been assigned.
A possible solution is to provide a two-step method for object creation. That is, in addition to Component::createObject(), have e.g. allocateObject() and finalizeObject() (which basically call beginCreate() and completeCreate() in QDeclarativeComponent) so you can do:
component = Qt.createComponent("Sprite.qml"); sprite = component.allocateObject(appWindow); if (sprite != null) { sprite.x = 100; sprite.y = 100; sprite.specialProperty = someObject component.finalizeObject() }
This way the bindings are not evaluated until finalizeObject() is called, thus avoiding the errors.
Attachments
Issue Links
- depends on
-
QTBUG-13451 Support property versioning in QML
- Closed