[Qt-qml] Dynamically created items and properties

bea.lam at nokia.com bea.lam at nokia.com
Mon Aug 23 10:13:05 CEST 2010


Hi Jan,

> The destruction is not triggered there yet, it happens much later when the user does some
> actions. The errors come immediately when the Unit is created. The unit does work and all the
> bindings seem to get updated, but the initial stream of errors is a bit worrying to me.
> 

Sorry, you are correct, the errors are triggered on construction. I've created http://bugreports.qt.nokia.com/browse/QTBUG-13087 for this.

> 
> and later in a PropertyChanges as above set the target to the now valid "unit". This does not really work, as
> the PropertyChanges would look like:
> 
> PropertyChanges {
>    target: connection
>    target: unit
> }
> 
> Slight problem there:
> 
> foo.qml: Property value set multiple times
> 
> Is there any way to make that actually work? Some magic escaping or similar? These hacks should
> not really be needed at all, but as long as they are, more workarounds are needed.
> 

Bug created as http://bugreports.qt.nokia.com/browse/QTBUG-13089.

In the meantime, one workaround is to bind the target to some other property, and then change that other property:

Item { 
    id: container
    property alias connTarget: conn.target

    states: State {
        name: "myState"; when: unit != undefined
        PropertyChanges { target: container; connTarget: unit }
    }

    Connections {
        id: conn
        onWhateverChanged: doStuff()
    }
}



> I'm sorry for being such a pain in the rectal regions, but I've invested so much time in this project now
> for it to stumble and collapse at the final stages of development.
> 


Thanks for sharing these issues - we want to improve QML, and this is really useful for improving the support for dynamic object management.


regards,

Bea





More information about the Qt-qml mailing list