[Interest] QML properties
Jason H
jhihn at gmx.com
Tue Apr 12 17:17:19 CEST 2016
> Hi,
>
> How to correctly name that that when in QML I write "width:
> parent.width / 2", for example, then when parent.width changed then
> changed and width too? I.e. automatic propagation?
Realize that QML properties are Q_PROPERTY, with an onPROPERTYChanged emit event. In this way, when parent.width changes, it fires off the event and any variable connected with a binding (explicitly or implicitly) is recalculated.
Also, realize that you can declare your own properties in QML:
Rectangle {
property int verticalDivisor: 15
Rectangle {
height: parent.height / verticalDivisor
}
onVerticalDivisorChanged: console.log("verticalDivisor:", verticalDivisor)
Behavior on verticalDivisor {
NumberAnimation { ...etc...}
}
}
Now you can animate vertical divisor, as well as provide onVerticalDivisorChanged event handling, as shown above.
More information about the Interest
mailing list