Help on states and transitions
-
Hi, I'm trying to understand how the states and transitions works togheter. Basically, I have some variables that define the current state. For example, let's say we have:
property bool isActive: myClass.isActive
where
myClass
is a C++ class which has a notifiable property calledisActive
.
I want to animate some objects when this property changes. I tried this code:states: [ State { name: "ACTIVE"; when: myClass.isActive PropertyChanges { target: areaContents; x: 0 } PropertyChanges { target: areaHeader; opacity: 1.0 } PropertyChanges { target: areaFooter; opacity: 1.0 } }, State { name: "NOTACTIVE"; when: !myClass.isActive PropertyChanges { target: areaContents; x: -width } PropertyChanges { target: areaHeader; opacity: 0.0 } PropertyChanges { target: areaFooter; opacity: 0.0 } } ] transitions: [ Transition { NumberAnimation { target: areaContents; property: "x"; duration: 500; easing.type: Easing.InOutQuad } OpacityAnimator { target: areaHeader; duration: 500 } OpacityAnimator { target: areaFooter; duration: 500 } } ]
But it doens't work as excpected.
Few questions:- do I need to explicitly define values for both states? I mean, in the
NOTACTIVE
state the properties' values are the same declared into the definition of the object ("default" ones) - is it correct how I animate the properties? I'm not sure because in the *Animators you can also specify the
from
andto
values. When not specified they use the ones provided from thePropertyChanges
objects?
- do I need to explicitly define values for both states? I mean, in the
-
@Mark81 said:
- is it correct how I animate the properties? I'm not sure because in the *Animators you can also specify the
from
andto
values. When not specified they use the ones provided from thePropertyChanges
objects?
you should define at least the "to" properties. The from - if left out - should use the current value.
Of course without a to-value, who should know until which value you want the animation to happen. - is it correct how I animate the properties? I'm not sure because in the *Animators you can also specify the
-
@raven-worx said:
Of course without a to-value, who should know until which value you want the animation to happen.
I'm not sure to understand this. If I have to specify to to-value in the *Animator objects, what is the purpose of the PropertyChanges?
-
@Mark81
forget what i said, this wasn't correct. sorry.In the Transition object you should fill the "from" and "to" porperties with names of the states.
So you need a transition from state to state.