diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-22 13:10:35 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-22 13:23:06 (GMT) |
commit | 1a55f40b6223511d0eb388064597ab38a0d37627 (patch) | |
tree | 522d9fafe3bef5049b75471b266ab2f614dfa412 /examples/animation/states/main.cpp | |
parent | df2a1de1720476d096ad9be0a8cf5a0410206d82 (diff) | |
download | Qt-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/states/main.cpp')
-rw-r--r-- | examples/animation/states/main.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/examples/animation/states/main.cpp b/examples/animation/states/main.cpp index b3c28f2..99e04c3 100644 --- a/examples/animation/states/main.cpp +++ b/examples/animation/states/main.cpp @@ -124,10 +124,9 @@ int main(int argc, char *argv[]) scene.addItem(p6); QStateMachine machine; - QState *root = machine.rootState(); - QState *state1 = new QState(root); - QState *state2 = new QState(root); - QState *state3 = new QState(root); + QState *state1 = new QState(&machine); + QState *state2 = new QState(&machine); + QState *state3 = new QState(&machine); machine.setInitialState(state1); // State 1 |