summaryrefslogtreecommitdiffstats
path: root/examples/statemachine
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-05-12 17:02:27 +0200
committerKent Hansen <khansen@trolltech.com>2009-05-12 17:02:52 +0200
commit3db6f6234eb36ec4b3d6e14dc48917762653cbd7 (patch)
treeec702b5e7c11f661cfd00679530045daa1c8b5c2 /examples/statemachine
parentb6c082925a6fd51d05fcba6276d1cb9bd5886374 (diff)
document the statemachine/eventtransitions example
Diffstat (limited to 'examples/statemachine')
-rw-r--r--examples/statemachine/eventtransitions/main.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/examples/statemachine/eventtransitions/main.cpp b/examples/statemachine/eventtransitions/main.cpp
index f564b7e551..aba0c73a8e 100644
--- a/examples/statemachine/eventtransitions/main.cpp
+++ b/examples/statemachine/eventtransitions/main.cpp
@@ -46,6 +46,7 @@
#include <qeventtransition.h>
#endif
+//! [0]
class Window : public QWidget
{
public:
@@ -54,7 +55,9 @@ public:
{
QPushButton *button = new QPushButton(this);
button->setGeometry(QRect(100, 100, 100, 100));
+//! [0]
+//! [1]
QStateMachine *machine = new QStateMachine(this);
QState *s1 = new QState();
@@ -62,15 +65,21 @@ public:
QState *s2 = new QState();
s2->assignProperty(button, "text", "Inside");
+//! [1]
+//! [2]
QEventTransition *enterTransition = new QEventTransition(button, QEvent::Enter);
enterTransition->setTargetState(s2);
s1->addTransition(enterTransition);
+//! [2]
+//! [3]
QEventTransition *leaveTransition = new QEventTransition(button, QEvent::Leave);
leaveTransition->setTargetState(s1);
s2->addTransition(leaveTransition);
+//! [3]
+//! [4]
QState *s3 = new QState();
s3->assignProperty(button, "text", "Pressing...");
@@ -81,16 +90,20 @@ public:
QEventTransition *releaseTransition = new QEventTransition(button, QEvent::MouseButtonRelease);
releaseTransition->setTargetState(s2);
s3->addTransition(releaseTransition);
+//! [4]
+//! [5]
machine->addState(s1);
machine->addState(s2);
machine->addState(s3);
+
machine->setInitialState(s1);
- QObject::connect(machine, SIGNAL(finished()), qApp, SLOT(quit()));
machine->start();
}
};
+//! [5]
+//! [6]
int main(int argc, char **argv)
{
QApplication app(argc, argv);
@@ -100,3 +113,4 @@ int main(int argc, char **argv)
return app.exec();
}
+//! [6]