diff options
Diffstat (limited to 'examples/animation')
-rw-r--r-- | examples/animation/appchooser/main.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/animation/appchooser/main.cpp b/examples/animation/appchooser/main.cpp index 02302d9..1c63aba 100644 --- a/examples/animation/appchooser/main.cpp +++ b/examples/animation/appchooser/main.cpp @@ -90,15 +90,16 @@ void createStates(const QObjectList &objects, for (int i = 0; i < objects.size(); ++i) { QState *state = new QState(parent); state->assignProperty(objects.at(i), "geometry", selectedRect); - QAbstractTransition *trans = parent->addTransition(objects.at(i), SIGNAL(clicked()), state); - for (int j = 0; j < objects.size(); ++j) { - QPropertyAnimation *animation = new QPropertyAnimation(objects.at(j), "geometry"); - animation->setDuration(2000); - trans->addAnimation(animation); - } + parent->addTransition(objects.at(i), SIGNAL(clicked()), state); } } +void createAnimations(const QObjectList &objects, QStateMachine *machine) +{ + for (int i=0; i<objects.size(); ++i) + machine->addDefaultAnimation(new QPropertyAnimation(objects.at(i), "geometry")); +} + int main(int argc, char **argv) { Q_INIT_RESOURCE(appchooser); @@ -143,7 +144,10 @@ int main(int argc, char **argv) QState *idleState = new QState(group); group->setInitialState(idleState); - createStates(QObjectList() << p1 << p2 << p3 << p4, selectedRect, group); + QObjectList objects; + objects << p1 << p2 << p3 << p4; + createStates(objects, selectedRect, group); + createAnimations(objects, &machine); machine.setInitialState(group); machine.start(); |