diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-06-04 17:27:45 +0200 |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-06-04 17:27:45 +0200 |
commit | 8cb8180b4baf6555d956f5293fd9392bdcebee89 (patch) | |
tree | 39bc94e586ae45e7f8ac243f4b9818fcabf98d74 | |
parent | 57dc43f74ce316053886723bb9060fda4baeca47 (diff) |
Two-way button state machine example ported to QtScript
-rw-r--r-- | examples/TwoWayButton.qs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/TwoWayButton.qs b/examples/TwoWayButton.qs new file mode 100644 index 0000000..d4d5dcc --- /dev/null +++ b/examples/TwoWayButton.qs @@ -0,0 +1,21 @@ +var button = new QPushButton(); + +var off = new QState(); +off.assignProperty(button, "text", "Off"); + +var on = new QState(); +on.assignProperty(button, "text", "On"); + +off.addTransition(button, "clicked()", on); +on.addTransition(button, "clicked()", off); + +var machine = new QStateMachine(); +machine.addState(off); +machine.addState(on); +machine.initialState = off; + +machine.start(); +button.resize(100, 100); +button.show(); + +QCoreApplication.exec(); |