[Qt-qml] property "alias" on run-time
Leonardo Cunha
leo.cunha at nokia.com
Thu Sep 2 18:13:09 CEST 2010
hi,
the switches example in qt-components/examples/gallery does exactly what you
want:
Item {
Grid {
anchors.fill: parent
Switch {
id: switch1
}
Label {
text: "First switch is " + (switch1.enabled ? "ENABLED" :
"Disabled")
}
Switch {
id: switch2
}
Label {
text: "Second switch is " + (switch2.enabled ? "ENABLED" :
"Disabled")
}
Switch {
id: bindSwitch
Binding {
target: switch1
property: "enabled"
value: switch2.enabled
when: bindSwitch.enabled
}
Binding {
target: switch2
property: "enabled"
value: switch1.enabled
when: bindSwitch.enabled
}
}
Label {
text: "Bind the values of the two switches above"
}
}
}
br,
// leo
From: qt-qml-bounces at trolltech.com [mailto:qt-qml-bounces at trolltech.com] On
Behalf Of Jokela Pekka.E (Nokia-MS/Tampere)
Sent: Thursday, September 02, 2010 7:16 AM
To: qt-qml at trolltech.com
Subject: [Qt-qml] property "alias" on run-time
Hi,
I have a two properties
property var A
property var B
and Id like to have them equal when condition C is met i.e. two way binding
i.e. as property alias B: A
So, when C is met:
-changing A changes B to be equal to A
-changing B changes A to be equal to B
When C is not met, the A and B can be changed independently without changing
each other.
I tried something like:
states: [
State {
name: "C met"
when: C == true
PropertyChanges { A: B }
PropertyChanges { B: A }
}
]
But I think the latter one cancels the first one to avoid infinite loops.
Any pointers?
More information about the Qt-qml
mailing list