Hi again,
Since my previous post, we've been using the
QAnimationState class together with the convenience method
addAnimateTransition() to get animated transitions between states. Now the API's got even cleaner and easier to understand, you don't have to use a special state in order to associate animated transitions to it any longer ;) I've updated the Qt's documentation about the animation framework, you can read it below:
Animations and States
When using a state machine, we can associate an animation to a transition between states using a
QSignalTransition or
QEventTransition class. These classes are both derived from
QAbstractTransition, which defines the convenience function
addAnimation() that enables the appending of one or more animations triggered when the transition occurs.
We also have the possibility to associate properties with the states rather than setting the start and end values ourselves. Below is a complete code example that animates the geometry of a
QPushButton.
QPushButton *button = new QPushButton("Animated Button");
button->show();
QStateMachine *machine = new QStateMachine;
QState *state1 = new QState(machine->rootState());
state1->assignProperty(button, "geometry", QRect(0, 0, 100, 30));
machine->setInitialState(state1);
QState *state2 = new QState(machine->rootState());
state2->assignProperty(button, "geometry", QRect(250, 250, 100, 30));
QSignalTransition *transition1 = state1->addTransition(button,
SIGNAL(clicked()), state2);
transition1->addAnimation(new QPropertyAnimation(button, "geometry"));
QSignalTransition *transition2 = state2->addTransition(button,
SIGNAL(clicked()), state1);
transition2->addAnimation(new QPropertyAnimation(button, "geometry"));
machine->start();