summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-07-07 15:41:22 +0200
committerUlf Hermann <ulf.hermann@qt.io>2016-07-13 13:45:10 +0000
commit7b94a6394ed744c1132a679ac699231b097f416d (patch)
tree4158eeafd17369f0e582ba6edf57dd60ec376967 /examples
parente971720ccd51781ad93c74db94c72817a7cd2068 (diff)
Provide Qt5-style syntax for connectToState
We should not force people to use the string-based connection syntax. Using modern C++ we can add more convenience here. Unfortunately we have to duplicate some code from QMetaObject, but this is worth it. Change-Id: I4daa1f7cfea9feb3de0159636a508ee64a849f55 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/scxml/pinball/mainwindow.cpp2
-rw-r--r--examples/scxml/trafficlight-common/trafficlight.cpp10
2 files changed, 6 insertions, 6 deletions
diff --git a/examples/scxml/pinball/mainwindow.cpp b/examples/scxml/pinball/mainwindow.cpp
index f2887f0..9e525c2 100644
--- a/examples/scxml/pinball/mainwindow.cpp
+++ b/examples/scxml/pinball/mainwindow.cpp
@@ -124,7 +124,7 @@ MainWindow::~MainWindow()
void MainWindow::initAndConnect(const QString &state, QWidget *widget)
{
widget->setEnabled(m_machine->isActive(state));
- m_machine->connectToState(state, widget, SLOT(setEnabled(bool)));
+ m_machine->connectToState(state, widget, &QWidget::setEnabled);
}
void MainWindow::eventOccurred(const QScxmlEvent &event)
diff --git a/examples/scxml/trafficlight-common/trafficlight.cpp b/examples/scxml/trafficlight-common/trafficlight.cpp
index c14d4dc..66ed289 100644
--- a/examples/scxml/trafficlight-common/trafficlight.cpp
+++ b/examples/scxml/trafficlight-common/trafficlight.cpp
@@ -103,15 +103,15 @@ TrafficLight::TrafficLight(QScxmlStateMachine *machine, QWidget *parent)
setFixedSize(widget->sizeHint());
machine->connectToState(QStringLiteral("red"),
- widget->redLight(), SLOT(switchLight(bool)));
+ widget->redLight(), &LightWidget::switchLight);
machine->connectToState(QStringLiteral("redGoingGreen"),
- widget->redLight(), SLOT(switchLight(bool)));
+ widget->redLight(), &LightWidget::switchLight);
machine->connectToState(QStringLiteral("yellow"),
- widget->yellowLight(), SLOT(switchLight(bool)));
+ widget->yellowLight(), &LightWidget::switchLight);
machine->connectToState(QStringLiteral("blinking"),
- widget->yellowLight(), SLOT(switchLight(bool)));
+ widget->yellowLight(), &LightWidget::switchLight);
machine->connectToState(QStringLiteral("green"),
- widget->greenLight(), SLOT(switchLight(bool)));
+ widget->greenLight(), &LightWidget::switchLight);
QAbstractButton *button = new ButtonWidget(this);
auto setButtonGeometry = [this, button](){