blob: a124623cd734bb21800444d869dc0384ada6d284 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
** $TROLLTECH_DUAL_LICENSE$
**
****************************************************************************/
#include <QtCore>
#ifdef QT_STATEMACHINE_SOLUTION
#include <qstatemachine.h>
#include <qstate.h>
#include <qfinalstate.h>
#endif
class S0 : public QState
{
public:
S0(QState *parent = 0)
: QState(parent) {}
virtual void onEntry()
{
fprintf(stdout, "Hello world!\n");
}
};
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QStateMachine machine;
QState *s0 = new S0();
QFinalState *s1 = new QFinalState();
s0->addTransition(s1);
machine.addState(s0);
machine.addState(s1);
machine.setInitialState(s0);
QObject::connect(&machine, SIGNAL(finished()), QCoreApplication::instance(), SLOT(quit()));
machine.start();
return app.exec();
}
|