A Simple Qt State Machine
Posted on quinta-feira, abril 16th, 2009 at 16:19Hi,
today I will post the source code for the following satechart for a simple Qt state machine.

You can get the source code here.
—
QPushButton button("Ok");
/* The state machine. */
QStateMachine machine;
/* Three states to the state machine. */
QState s1;
QState s2;
QState s3;
/* For each state it sets the button's text property. */
s1.setPropertyOnEntry(&button, "text", "In state S[1]");
s2.setPropertyOnEntry(&button, "text", "In state S[2]");
s3.setPropertyOnEntry(&button, "text", "In state S[3]");
/* Adds the transitions to each state */
s1.addTransition(&button, SIGNAL(clicked()), &s2);
s2.addTransition(&button, SIGNAL(clicked()), &s3);
s3.addTransition(&button, SIGNAL(clicked()), &s1);
/* Adds the three states s1, s2 and s3 to the state machine. */
machine.addState(&s1);
machine.addState(&s2);
machine.addState(&s3);
/* Sets the state s1 as initial state. */
machine.setInitialState(&s1);
/* Starts the state machine. */
machine.start();
button.show();
—
When any of the states is entered, the button’s text will be changed accordingly.
Reference:
http://doc.trolltech.com/solutions/4/qtanimationframework/statemachine-api.html

Olga …
Otkuda material ? …