Home

QtAnimationState Class Reference
[QtCore module]

The QtAnimationState class provides a state that plays one or more animations. More...

 #include <QtAnimationState>

This class is under development and is subject to change.

Inherits QtState.

Public Functions

Additional Inherited Members


Detailed Description

The QtAnimationState class provides a state that plays one or more animations.

QtAnimationState is part of The State Machine Framework.

The addAnimation() function adds an animation to be played by the state.

When the state is entered, it will call each of the animations' start() functions. When the animation is finished, a QtStateFinishedEvent is posted; you can use the QtStateFinishedTransition class to associate a transition with this event.

 QPushButton button;
 QtPropertyAnimation animation(&button, "geometry");
 animation.setEndValue(QRect(100, 100, 400, 400));

 QtStateMachine machine;
 QtAnimationState *s1 = new QtAnimationState(&animation, machine.rootState());
 QtState *s2 = new QtState(machine.rootState());
 s1->addFinishedTransition(s2);

If the state is exited before the animation has finished, the animations will be stopped, and no event is generated.

For convenience, the QtState::addAnimatedTransition() functions can be used to set up the animated transition between two states.

Initializing animations automatically

QtAnimationState will try to automatically initialize any QtPropertyAnimation for which no specific end value has been set. It will set the animation's end value based on actions in the target state of the animation state's QtStateFinishedTransition.

The only actions evaluated are the entry actions of the very first states entered after the animation state has finished.

QtAnimationState will match its QtPropertyAnimation objects with QtStateSetPropertyAction objects in the target states that manipulate the same property on the same object. The end values of the animations will be initialized to the values set by the actions.

 QPushButton button;
 QtPropertyAnimation animation(&button, "geometry");

 QtStateMachine machine;
 QtAnimationState *s1 = new QtAnimationState(&animation, machine.rootState());
 QtState *s2 = new QtState(machine.rootState());
 s2->setPropertyOnEntry(&button, "geometry", QRect(100, 100, 400, 400));

 s1->addFinishedTransition(s2);

Specifically, QtAnimationState will evaluate the actions set for the target state itself, and also look in following locations: objects:

Children of the target state will be evaluated recursively.

Animated restoring of properties

When a state has restore policy QtActionState::RestoreProperties, any property that is set in the state using the QtStateSetPropertyAction will potentially be restored to its original value later on. When regular, unanimated transitions are used, the properties will be restored when the state machine enters one or more states that do not explicitly set the property.

When QtAnimationState is used, it will restore the property with an animation. Rather than have the state machine restore the properties as it enters the target state, they will be restored by the QtAnimationState in parallel to the regular animations that have been added to the state.

If no animation has been added to the state, only the restore animations will be played.

The animations used to restore the properties are QtPropertyAnimations with with the default easing curve and duration.

See also QtActionState::RestorePolicy, QtPropertyAnimation, QtStateSetPropertyAction, and QtState::addAnimatedTransition().


Member Function Documentation

QtAnimationState::QtAnimationState ( QtAbstractAnimation * animation, QtState * parent = 0 )

Constructs a new QtAnimationState object with the given animation and parent state

QtAnimationState::QtAnimationState ( QtState * parent = 0 )

Constructs a new QtAnimationState object with the given parent state.

QtAnimationState::~QtAnimationState ()

Destroys this QtAnimationState.

void QtAnimationState::addAnimation ( QtAbstractAnimation * animation )

Adds animation to this QtAnimationState.

QtAbstractAnimation * QtAnimationState::animationAt ( int i ) const

Returns the animation associated with this QtAnimationState at index i.

int QtAnimationState::animationCount () const

Returns the number of animations added to this QtAnimationState.

void QtAnimationState::removeAnimation ( QtAbstractAnimation * animation )

Removes animation from this QtAnimationState.


Copyright © 2009 Nokia Trademarks
Qt Solutions