summaryrefslogtreecommitdiffstats
path: root/examples/animation/stickman
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-07-22 13:10:35 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-07-22 13:23:06 (GMT)
commit1a55f40b6223511d0eb388064597ab38a0d37627 (patch)
tree522d9fafe3bef5049b75471b266ab2f614dfa412 /examples/animation/stickman
parentdf2a1de1720476d096ad9be0a8cf5a0410206d82 (diff)
downloadQt-1a55f40b6223511d0eb388064597ab38a0d37627.zip
Qt-1a55f40b6223511d0eb388064597ab38a0d37627.tar.gz
Qt-1a55f40b6223511d0eb388064597ab38a0d37627.tar.bz2
Make QStateMachine inherit QState
This removes the need for a "root state" in the machine; or rather, the machine _is_ the root state. User code can now pass in a QStateMachine directly to the QState constructor, instead of machine->rootState(). This also means we could get rid of the "proxying" from the machine to the root state for things like properties (initialState et al), finished() signal and auto-reparenting of states (the ChildAdded event hack). A fun little side-effect of this change is that it's now possible to embed state machines within state machines. We can't think of a good use case yet where you would rather embed a stand-alone state machine (with its own event processing etc.) rather than having just a regular nested state, but it's neat and it works. Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'examples/animation/stickman')
-rw-r--r--examples/animation/stickman/lifecycle.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp
index 2a54c82..c761d87 100644
--- a/examples/animation/stickman/lifecycle.cpp
+++ b/examples/animation/stickman/lifecycle.cpp
@@ -108,11 +108,11 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
m_machine->addDefaultAnimation(m_animationGroup);
//! [3]
- m_alive = new QState(m_machine->rootState());
+ m_alive = new QState(m_machine);
m_alive->setObjectName("alive");
// Make it blink when lightning strikes before entering dead animation
- QState *lightningBlink = new QState(m_machine->rootState());
+ QState *lightningBlink = new QState(m_machine);
lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::white);
lightningBlink->assignProperty(m_stickMan, "penColor", Qt::black);
lightningBlink->assignProperty(m_stickMan, "fillColor", Qt::white);
@@ -126,7 +126,7 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
QObject::connect(lightningBlink, SIGNAL(exited()), timer, SLOT(stop()));
//! [5]
- m_dead = new QState(m_machine->rootState());
+ m_dead = new QState(m_machine);
m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::black);
m_dead->assignProperty(m_stickMan, "penColor", Qt::white);
m_dead->assignProperty(m_stickMan, "fillColor", Qt::black);