summaryrefslogtreecommitdiffstats
path: root/examples/scxml/trafficlight-qml-dynamic
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@theqtcompany.com>2016-08-24 14:34:19 +0200
committerThomas Hartmann <Thomas.Hartmann@theqtcompany.com>2016-09-02 09:11:28 +0000
commit0be24d1e025fea75ad8c2730fea30e9fed8789dd (patch)
tree06fb8c89001f6874a9a641dd9fed685576098d96 /examples/scxml/trafficlight-qml-dynamic
parent9a9861b2a7063b50913abcd2c25328d560e71491 (diff)
Examples: Use a proper type for the stateMachine property
This is required to get auto completion working in TrafficLight.qml. (At least for the static case) Change-Id: I9fd3ca64ff92b62cb30e0c66eab20c60995ff911 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'examples/scxml/trafficlight-qml-dynamic')
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp b/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp
index b862386..a8bf00e 100644
--- a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp
+++ b/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp
@@ -51,11 +51,20 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
+#include <QScxmlStateMachine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
+ /* Register QScxmlStateMachine as TrafficLightStateMachine. This is required to have a type
+ * for the state machine and allows full code completion in the static case, since we
+ * share the QML code. */
+ qmlRegisterUncreatableType<QScxmlStateMachine>("TrafficLightStateMachine",
+ 1, 0,
+ "TrafficLightStateMachine",
+ QLatin1String("TrafficLightStateMachine is not creatable."));
+
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///trafficlight-qml-dynamic.qml")));
if (engine.rootObjects().isEmpty())