summaryrefslogtreecommitdiffstats
path: root/examples/statemachine
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-05-12 13:51:39 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-05-12 14:05:36 (GMT)
commite863e3195e90db89c29603508e6857a5cc874ca4 (patch)
treeed462df98b347c09e01a318af2a9002221668c44 /examples/statemachine
parent90d801f05f64c645f0899e3d81b23ecf53bf4835 (diff)
downloadQt-e863e3195e90db89c29603508e6857a5cc874ca4.zip
Qt-e863e3195e90db89c29603508e6857a5cc874ca4.tar.gz
Qt-e863e3195e90db89c29603508e6857a5cc874ca4.tar.bz2
document the statemachine/pingpong example
Diffstat (limited to 'examples/statemachine')
-rw-r--r--examples/statemachine/pingpong/main.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/statemachine/pingpong/main.cpp b/examples/statemachine/pingpong/main.cpp
index eb8fd5d..db66bfd 100644
--- a/examples/statemachine/pingpong/main.cpp
+++ b/examples/statemachine/pingpong/main.cpp
@@ -47,6 +47,7 @@
#include <qabstracttransition.h>
#endif
+//! [0]
class PingEvent : public QEvent
{
public:
@@ -60,7 +61,9 @@ public:
PongEvent() : QEvent(QEvent::Type(QEvent::User+3))
{}
};
+//! [0]
+//! [1]
class Pinger : public QState
{
public:
@@ -74,7 +77,9 @@ protected:
fprintf(stdout, "ping?\n");
}
};
+//! [1]
+//! [3]
class PongTransition : public QAbstractTransition
{
public:
@@ -90,7 +95,9 @@ protected:
fprintf(stdout, "ping?\n");
}
};
+//! [3]
+//! [2]
class PingTransition : public QAbstractTransition
{
public:
@@ -106,7 +113,9 @@ protected:
fprintf(stdout, "pong!\n");
}
};
+//! [2]
+//! [4]
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
@@ -114,7 +123,9 @@ int main(int argc, char **argv)
QStateMachine machine;
QState *group = new QState(QState::ParallelStates);
group->setObjectName("group");
+//! [4]
+//! [5]
Pinger *pinger = new Pinger(group);
pinger->setObjectName("pinger");
pinger->addTransition(new PongTransition());
@@ -122,10 +133,13 @@ int main(int argc, char **argv)
QState *ponger = new QState(group);
ponger->setObjectName("ponger");
ponger->addTransition(new PingTransition());
+//! [5]
+//! [6]
machine.addState(group);
machine.setInitialState(group);
machine.start();
return app.exec();
}
+//! [6]