summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/statemachine/twowaybutton/main.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/examples/statemachine/twowaybutton/main.cpp b/examples/statemachine/twowaybutton/main.cpp
index 61a0f32..a2c6e45 100644
--- a/examples/statemachine/twowaybutton/main.cpp
+++ b/examples/statemachine/twowaybutton/main.cpp
@@ -45,34 +45,42 @@
#include <qstatemachine.h>
#endif
+//! [0]
int main(int argc, char **argv)
{
QApplication app(argc, argv);
-
QPushButton button;
-
QStateMachine machine;
- QState *first = new QState();
- first->setObjectName("first");
+//! [0]
+//! [1]
QState *off = new QState();
off->assignProperty(&button, "text", "Off");
off->setObjectName("off");
- first->addTransition(off);
QState *on = new QState();
on->setObjectName("on");
on->assignProperty(&button, "text", "On");
+//! [1]
+
+//! [2]
off->addTransition(&button, SIGNAL(clicked()), on);
on->addTransition(&button, SIGNAL(clicked()), off);
+//! [2]
- machine.addState(first);
+//! [3]
machine.addState(off);
machine.addState(on);
- machine.setInitialState(first);
+//! [3]
+
+//! [4]
+ machine.setInitialState(off);
machine.start();
+//! [4]
+//! [5]
button.resize(100, 50);
button.show();
return app.exec();
}
+//! [5]