summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2016-03-10 10:23:42 +0100
committerUlf Hermann <ulf.hermann@theqtcompany.com>2016-03-30 11:56:31 +0000
commit40914b6c47945dbce11f4993cd0dcf4f640161b3 (patch)
treee266e0e786d7dca2a854a8275f4e595706459497 /examples
parente59c66bed0fece56292c81d30bb199a4a2b1989d (diff)
Make data models QObjects, and rename some members to avoid clashes
We will have one data model per state machine, so the overhead of creating a QObject won't be significant. However, we can expose the data model to QML this way. Also, by using QObjectPrivate, we can actually drop a few d-pointers. Change-Id: I8a73dde017e8fd38032f4948e2946590456b4cc9 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc9
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp2
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h1
3 files changed, 7 insertions, 5 deletions
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc b/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc
index 9cf1603..633922a 100644
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc
+++ b/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc
@@ -61,10 +61,11 @@
\skipto qscxmlcppdatamodel.h
\printuntil Q_SCXML_DATAMODEL
- We place the \c Q_SCXML_DATAMODEL macro in the private section of the
- definition, right after the opening bracket. The macro expands to the
- declaration of virtual methods, the implementation of which is generated by
- the Qt SCXML compiler.
+ QScxmlCppDataModel derives from QObject, so we add the \c Q_OBJECT macro in
+ the private section of the definition, right after the opening bracket. We
+ then place the \c Q_SCXML_DATAMODEL macro after \c Q_OBJECT. The macro
+ expands to the declaration of virtual methods, the implementation of which
+ is generated by the Qt SCXML compiler.
In the SCXML file, we specify C++ statements in the \c <script> element and
use the \e expr attribute to access the data model:
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp b/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp
index aa0e427..b4409ef 100644
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp
+++ b/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp
@@ -65,5 +65,5 @@ bool TheDataModel::isValidMedia() const
QVariantMap TheDataModel::eventData() const
{
- return event().data().value<QVariantMap>();
+ return scxmlEvent().data().value<QVariantMap>();
}
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h b/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h
index 5c07436..e0f5bdf 100644
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h
+++ b/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h
@@ -55,6 +55,7 @@
class TheDataModel: public QScxmlCppDataModel
{
+ Q_OBJECT
Q_SCXML_DATAMODEL
public: