summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@theqtcompany.com>2016-08-25 14:32:32 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2016-08-26 13:48:25 +0000
commita34e5cda67c92021d6999b3544669cdbbd9655f8 (patch)
tree423041c353463a595cb0898a8cccb751f76df97c /examples
parent4b0e41ade98f1540018b0388eea071a0a6c8c429 (diff)
Small corrections to examples
Fix docs accordingly. Change-Id: Ib008cc841f7533ff7f32ae134dfd4f6a8b36df15 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc2
-rw-r--r--examples/scxml/mediaplayer-common/mainwindow.h2
-rw-r--r--examples/scxml/pinball/doc/src/pinball.qdoc17
-rw-r--r--examples/scxml/pinball/mainwindow.cpp22
-rw-r--r--examples/scxml/pinball/mainwindow.h10
-rw-r--r--examples/scxml/trafficlight-common/trafficlight.h2
6 files changed, 23 insertions, 32 deletions
diff --git a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc
index 08a152b..207f47d 100644
--- a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc
+++ b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc
@@ -12,5 +12,5 @@
corresponding signals:
\quotefromfile mediaplayer-common/mainwindow.cpp
- \skipto connect(ui
+ \skipto connectToEvent
\printuntil playbackStopped
diff --git a/examples/scxml/mediaplayer-common/mainwindow.h b/examples/scxml/mediaplayer-common/mainwindow.h
index 38bb39f..c89c269 100644
--- a/examples/scxml/mediaplayer-common/mainwindow.h
+++ b/examples/scxml/mediaplayer-common/mainwindow.h
@@ -71,7 +71,7 @@ public:
explicit MainWindow(QScxmlStateMachine *stateMachine, QWidget *parent = 0);
~MainWindow();
-public slots:
+private slots:
void started(const QScxmlEvent &event);
void stopped(const QScxmlEvent &event);
diff --git a/examples/scxml/pinball/doc/src/pinball.qdoc b/examples/scxml/pinball/doc/src/pinball.qdoc
index 2dd9949..81a35aa 100644
--- a/examples/scxml/pinball/doc/src/pinball.qdoc
+++ b/examples/scxml/pinball/doc/src/pinball.qdoc
@@ -423,12 +423,12 @@
\printuntil /^\ {16}<\//
When we receive the \c updateLights event, we first want to send a
- \c updateScore signal outside of the state machine. We pass
- the current values of the \c highScore and \c score variables to the signal.
- This signal is received by the C++ part.
+ \c updateScore event outside of the state machine. We pass
+ the current values of the \c highScore and \c score variables to the event.
+ This event is received by the C++ part.
Next, depending on whether we are in \c jackpotStateOn or \c jackpotStateOff,
- we send the \c turnOnJackpot or the \c turnOffJackpot signal,
+ we send the \c turnOnJackpot or the \c turnOffJackpot event,
which instructs the \c guiControl state to transition to
\c jackpotLightOn or \c jackpotLightOff, respectively.
@@ -454,7 +454,7 @@
The class is declared in \e mainwindow.h.
\quotefromfile pinball/mainwindow.h
- \skipto Pinball
+ \skipto MainWindow
\printuntil };
The \c MainWindow class holds the pointer to the
@@ -482,10 +482,9 @@
the widget is disabled. We do that for all lights, targets,
and description labels.
- We also connect to the \c eventOccurred() signal, propagated
- by the state machine and intercept the \c updateScore
- event sent from the SCXML document in order to update
- the score displays with the values passed with the event.
+ We also intercept the \c updateScore event sent by the state machine,
+ in order to update the score displays with the values
+ passed with the event.
The info about hitting any GUI target needs to be passed
to the state machine and we do that by connecting
diff --git a/examples/scxml/pinball/mainwindow.cpp b/examples/scxml/pinball/mainwindow.cpp
index 1e7b13c..777de8a 100644
--- a/examples/scxml/pinball/mainwindow.cpp
+++ b/examples/scxml/pinball/mainwindow.cpp
@@ -52,11 +52,11 @@
#include "ui_mainwindow.h"
#include <QStringListModel>
-#include "pinball.h"
+#include <QScxmlStateMachine>
QT_USE_NAMESPACE
-MainWindow::MainWindow(Pinball *machine, QWidget *parent) :
+MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
QWidget(parent),
m_ui(new Ui::MainWindow),
m_machine(machine)
@@ -89,7 +89,13 @@ MainWindow::MainWindow(Pinball *machine, QWidget *parent) :
initAndConnect(QLatin1String("onState"), m_ui->ballOutButton);
// datamodel update
- m_machine->connectToEvent("updateScore", this, &MainWindow::eventOccurred);
+ m_machine->connectToEvent("updateScore", [this] (const QScxmlEvent &event) {
+ const QVariant data = event.data();
+ const QString highScore = data.toMap().value("highScore").toString();
+ m_ui->highScoreLabel->setText(highScore);
+ const QString score = data.toMap().value("score").toString();
+ m_ui->scoreLabel->setText(score);
+ });
// gui interaction
connect(m_ui->cButton, &QAbstractButton::clicked,
@@ -125,13 +131,3 @@ void MainWindow::initAndConnect(const QString &state, QWidget *widget)
widget->setEnabled(m_machine->isActive(state));
m_machine->connectToState(state, widget, &QWidget::setEnabled);
}
-
-void MainWindow::eventOccurred(const QScxmlEvent &event)
-{
- const QVariant data = event.data();
- const QString highScore = data.toMap().value("highScore").toString();
- m_ui->highScoreLabel->setText(highScore);
- const QString score = data.toMap().value("score").toString();
- m_ui->scoreLabel->setText(score);
-}
-
diff --git a/examples/scxml/pinball/mainwindow.h b/examples/scxml/pinball/mainwindow.h
index 174248c..57dffe7 100644
--- a/examples/scxml/pinball/mainwindow.h
+++ b/examples/scxml/pinball/mainwindow.h
@@ -57,26 +57,22 @@ QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
-class QScxmlEvent;
+class QScxmlStateMachine;
QT_END_NAMESPACE
-class Pinball;
class MainWindow : public QWidget
{
Q_OBJECT
public:
- explicit MainWindow(Pinball *machine, QWidget *parent = 0);
+ explicit MainWindow(QScxmlStateMachine *machine, QWidget *parent = 0);
~MainWindow();
-private slots:
- void eventOccurred(const QScxmlEvent &event);
-
private:
void initAndConnect(const QString &state, QWidget *widget);
QT_PREPEND_NAMESPACE(Ui::MainWindow) *m_ui;
- Pinball *m_machine;
+ QScxmlStateMachine *m_machine;
};
#endif // MAINWINDOW_H
diff --git a/examples/scxml/trafficlight-common/trafficlight.h b/examples/scxml/trafficlight-common/trafficlight.h
index cf9e22f..f64feda 100644
--- a/examples/scxml/trafficlight-common/trafficlight.h
+++ b/examples/scxml/trafficlight-common/trafficlight.h
@@ -63,7 +63,7 @@ class TrafficLight : public QWidget
public:
TrafficLight(QScxmlStateMachine *machine, QWidget *parent = 0);
-public slots:
+private slots:
void toggleWorking(bool pause);
private: