[Qt-qml] Dynamically created items and properties
Jan Ekholm
jan.ekholm at smultron.net
Mon Aug 23 10:35:03 CEST 2010
On Aug 23, 2010, at 11:13 AM, <bea.lam at nokia.com> wrote:
> 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()
> }
> }
This does not seem to work too well for me. Or, well, not at all actually. What I have is:
property alias connectionTarget: seenConnection.target
id: dummyId
states: [
State {
name: "UnitValid"
when: unit != undefined
PropertyChanges {
target: seenConnection
connectionTarget: unit
}
}
]
Connections {
id: seenConnection
onSeenChanged: visible = unit.seen
}
Hm, I hope this doesn't end up like a big ugly HTML mess. I'm still getting used to "Mail" on OSX. If
so let me know and I'll try to talk some sense into it.
Anyway, running the above gives:
... foo.qml: QML Connections: Cannot assign to non-existent property "onSeenChanged"
... foo.qml: QML PropertyChanges: Cannot assign to non-existent property "connectionTarget"
The connection is working though and my "onSeenChanged" gets called when it should, but the reason for this workaround was to get rid of errors, not double them. :)
--
Jan Ekholm
jan.ekholm at smultron.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100823/bcf9e3d6/attachment.html
More information about the Qt-qml
mailing list