summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/statemachine/main5.cpp
diff options
context:
space:
mode:
authorGeir Vattekar <geir.vattekar@trolltech.com>2009-06-18 12:04:19 (GMT)
committerGeir Vattekar <geir.vattekar@trolltech.com>2009-06-18 12:04:19 (GMT)
commit2114754f8f86e0b653b6057d9b46a30f97d51aef (patch)
tree33295ef5fe7181d626ff279387a246f9e353f487 /doc/src/snippets/statemachine/main5.cpp
parentde3093495ed17c3d6353dc413accc77ba54e51d4 (diff)
downloadQt-2114754f8f86e0b653b6057d9b46a30f97d51aef.zip
Qt-2114754f8f86e0b653b6057d9b46a30f97d51aef.tar.gz
Qt-2114754f8f86e0b653b6057d9b46a30f97d51aef.tar.bz2
Doc: Added snippet files for state machine overview.
Reviewed-by: Trust Me
Diffstat (limited to 'doc/src/snippets/statemachine/main5.cpp')
-rw-r--r--doc/src/snippets/statemachine/main5.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/doc/src/snippets/statemachine/main5.cpp b/doc/src/snippets/statemachine/main5.cpp
new file mode 100644
index 0000000..90ad8c7
--- /dev/null
+++ b/doc/src/snippets/statemachine/main5.cpp
@@ -0,0 +1,103 @@
+
+#include <QtGui>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ {
+//![0]
+ QStateMachine machine;
+ machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+//![0]
+
+//![1]
+ QState *s1 = new QState();
+ s1->assignProperty(object, "fooBar", 1.0);
+ machine.addState(s1);
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState();
+ machine.addState(s2);
+//![1]
+ }
+
+ {
+
+//![2]
+ QStateMachine machine;
+ machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+
+ QState *s1 = new QState();
+ s1->assignProperty(object, "fooBar", 1.0);
+ machine.addState(s1);
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState(s1);
+ s2->assignProperty(object, "fooBar", 2.0);
+ s1->setInitialState(s2);
+
+ QState *s3 = new QState(s1);
+//![2]
+
+ }
+
+ {
+//![3]
+ QState *s1 = new QState();
+ QState *s2 = new QState();
+
+ s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
+ s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100));
+
+ s1->addTransition(button, SIGNAL(clicked()), s2);
+//![3]
+
+ }
+
+ {
+//![4]
+ QState *s1 = new QState();
+ QState *s2 = new QState();
+
+ s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
+ s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100));
+
+ QSignalTransition *transition = s1->addTransition(button, SIGNAL(clicked()), s2);
+ transition->addAnimation(new QPropertyAnimation(button, "geometry"));
+//![4]
+
+ }
+
+ {
+
+//![5]
+ QState *s1 = new QState();
+ s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
+
+ QState *s2 = new QState();
+
+ s1->addTransition(s1, SIGNAL(polished()), s2);
+//![5]
+
+ }
+
+ {
+
+//![6]
+ QState *s1 = new QState();
+ QState *s2 = new QState();
+
+ s2->assignProperty(object, "fooBar", 2.0);
+ s1->addTransition(s2);
+
+ QStateMachine machine;
+ machine.setInitialState(s1);
+ machine.addDefaultAnimation(new QPropertyAnimation(object, "fooBar"));
+//![6]
+
+ }
+
+ return app.exec();
+}
+