summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2009-09-07 12:53:59 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2009-09-07 12:54:51 (GMT)
commit23e1c7afed25ccb95cc24d2caa692853f35464ec (patch)
treec1413405d3b7944f53ed3028cdaa7bcd72c87625
parentf868eae7d0cd3297e2512b5651747fda689cc848 (diff)
downloadQt-23e1c7afed25ccb95cc24d2caa692853f35464ec.zip
Qt-23e1c7afed25ccb95cc24d2caa692853f35464ec.tar.gz
Qt-23e1c7afed25ccb95cc24d2caa692853f35464ec.tar.bz2
Doc: Added a note that a state machine requires a running event loop.
Reviewed-by: Trust Me
-rw-r--r--doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp15
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp42
2 files changed, 26 insertions, 31 deletions
diff --git a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
new file mode 100644
index 0000000..128799f
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
@@ -0,0 +1,15 @@
+//! [simple state machine]
+QPushButton button;
+
+QStateMachine machine;
+QState *s1 = new QState();
+s1->assignProperty(&button, "text", "Click me");
+
+QFinalState *s2 = new QFinalState();
+s1->addTransition(&button, SIGNAL(clicked()), s2);
+
+machine.addState(s1);
+machine.addState(s2);
+machine.setInitialState(s1);
+machine.start();
+//! [simple state machine]
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index f562fb3..a5cdd45 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -78,13 +78,13 @@
QT_BEGIN_NAMESPACE
/*!
- \class QStateMachine
- \reentrant
+ \class QStateMachine
+ \reentrant
- \brief The QStateMachine class provides a hierarchical finite state machine.
+ \brief The QStateMachine class provides a hierarchical finite state machine.
- \since 4.6
- \ingroup statemachine
+ \since 4.6
+ \ingroup statemachine
QStateMachine is based on the concepts and notation of
\l{Statecharts: A visual formalism for complex
@@ -128,21 +128,7 @@ QT_BEGIN_NAMESPACE
The following snippet shows a state machine that will finish when a button
is clicked:
- \code
- QPushButton button;
-
- QStateMachine machine;
- QState *s1 = new QState();
- s1->assignProperty(&button, "text", "Click me");
-
- QFinalState *s2 = new QFinalState();
- s1->addTransition(&button, SIGNAL(clicked()), s2);
-
- machine.addState(s1);
- machine.addState(s2);
- machine.setInitialState(s1);
- machine.start();
- \endcode
+ \snippet doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp simple state machine
This code example uses QState, which inherits QAbstractState. The
QState class provides a state that you can use to set properties
@@ -160,17 +146,7 @@ QT_BEGIN_NAMESPACE
no error state applies to the erroneous state, the machine will stop
executing and an error message will be printed to the console.
- \omit This stuff will be moved elsewhere
-This is
- typically used in conjunction with \l{Signals and Slots}{signals}; the
- signals determine the flow of the state graph, whereas the states' property
- assignments and method invocations are the actions.
-
- The postEvent() function posts an event to the state machine. This is useful
- when you are using custom events to trigger transitions.
- \endomit
-
- \sa QAbstractState, QAbstractTransition, QState, {The State Machine Framework}
+ \sa QAbstractState, QAbstractTransition, QState, {The State Machine Framework}
*/
/*!
@@ -1748,6 +1724,10 @@ bool QStateMachine::isRunning() const
transition to the initial state. When a final top-level state (QFinalState)
is entered, the machine will emit the finished() signal.
+ \note A state machine will not run without a running event loop, such as
+ the main application event loop started with QCoreApplication::exec() or
+ QApplication::exec().
+
\sa started(), finished(), stop(), initialState()
*/
void QStateMachine::start()