#include "stdafx.h"
#include "qtapplication03.h"
#include "ButtonChanged.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton button("State Machine");
QStateMachine machine;
ButtonChanged* bc = new ButtonChanged(&machine);
QState* s1 = new QState(&machine);
QState* s2 = new QState(&machine);
QState* s3 = new QState(&machine);
s1->assignProperty(&button, "geometry", QRect(100, 100, 120, 50));
s2->assignProperty(&button, "geometry", QRect(100, 100, 220, 50));
s3->assignProperty(&button, "geometry", QRect(100, 100, 320, 50));
s1->addTransition(&button, SIGNAL(clicked()), s2);
s2->addTransition(&button, SIGNAL(clicked()), s3);
s3->addTransition(&button, SIGNAL(clicked()), s1);
machine.setInitialState(s1);
machine.start();
button.show();
QObject::connect(s3, &QState::entered, bc, &ButtonChanged::changed);
return a.exec();
}