summaryrefslogtreecommitdiffstats
path: root/examples/scxml/pinball
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-07-07 16:15:02 +0200
committerUlf Hermann <ulf.hermann@qt.io>2016-07-14 10:44:54 +0000
commit2f2e31fea77aef558e5c6e3727f9b31cf018599a (patch)
treefccaf846d3c8c0f5e9287ccbb92caafd2c73a374 /examples/scxml/pinball
parent7b94a6394ed744c1132a679ac699231b097f416d (diff)
Better connection mechanism for events
The connectToEvent() mechanism is analogous to connectToState() and allows arbitrary event specifications, with '.' and '*'. In addition a QML component is provided to make event connections available in QML. Change-Id: Ie45422481a794b1b350347c383318857e5dc3f6d Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'examples/scxml/pinball')
-rw-r--r--examples/scxml/pinball/mainwindow.cpp9
1 files changed, 1 insertions, 8 deletions
diff --git a/examples/scxml/pinball/mainwindow.cpp b/examples/scxml/pinball/mainwindow.cpp
index 9e525c2..1e7b13c 100644
--- a/examples/scxml/pinball/mainwindow.cpp
+++ b/examples/scxml/pinball/mainwindow.cpp
@@ -89,8 +89,7 @@ MainWindow::MainWindow(Pinball *machine, QWidget *parent) :
initAndConnect(QLatin1String("onState"), m_ui->ballOutButton);
// datamodel update
- connect(m_machine, SIGNAL(eventOccurred(const QScxmlEvent &)),
- this, SLOT(eventOccurred(const QScxmlEvent &)));
+ m_machine->connectToEvent("updateScore", this, &MainWindow::eventOccurred);
// gui interaction
connect(m_ui->cButton, &QAbstractButton::clicked,
@@ -129,12 +128,6 @@ void MainWindow::initAndConnect(const QString &state, QWidget *widget)
void MainWindow::eventOccurred(const QScxmlEvent &event)
{
- if (event.originType() != QLatin1String("qt:signal"))
- return;
-
- if (event.name() != QLatin1String("updateScore"))
- return;
-
const QVariant data = event.data();
const QString highScore = data.toMap().value("highScore").toString();
m_ui->highScoreLabel->setText(highScore);