diff options
author | Eskil Abrahamsen Blomfeldt <eblomfel@trolltech.com> | 2009-05-06 08:25:41 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eblomfel@trolltech.com> | 2009-05-06 08:25:41 (GMT) |
commit | 48ca4182e518a6439264f87b54e691deecc59e20 (patch) | |
tree | 2e11833c047e8c2df765cf76b699e3c38bcd56a8 /examples | |
parent | a9fd7d6881107b7e06362076c587530124fb1484 (diff) | |
download | Qt-48ca4182e518a6439264f87b54e691deecc59e20.zip Qt-48ca4182e518a6439264f87b54e691deecc59e20.tar.gz Qt-48ca4182e518a6439264f87b54e691deecc59e20.tar.bz2 |
Instead of adding animations for all properties to all transitions, we use
the default animation concept, since this is its intended use.
Diffstat (limited to 'examples')
-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(); |