diff options
author | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-01-20 11:07:08 +0100 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-01-20 11:07:08 +0100 |
commit | a7b83d7d94345a01ba2824c8b3549f4361477694 (patch) | |
tree | bd414ba6893ad66c05af4c4d89528c6e4b09f2db /examples | |
parent | 7f0846f938f5024f5a89bb8e13c19bf745fe7445 (diff) |
Handle messages receival in example
Diffstat (limited to 'examples')
-rw-r--r-- | examples/mqtt/simpleclient/mainwindow.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/examples/mqtt/simpleclient/mainwindow.cpp b/examples/mqtt/simpleclient/mainwindow.cpp index 04492de..b87885f 100644 --- a/examples/mqtt/simpleclient/mainwindow.cpp +++ b/examples/mqtt/simpleclient/mainwindow.cpp @@ -24,6 +24,16 @@ MainWindow::MainWindow(QWidget *parent) : ui->editLog->insertPlainText(content); }); + connect(m_client, &QMqttClient::messageReceived, this, [this](const QString &topic, const QString &message) { + const QString content = QDateTime::currentDateTime().toString() + + QLatin1String(" Received Topic: ") + + topic + + QLatin1String(" Message: ") + + message + + QLatin1Char('\n'); + ui->editLog->insertPlainText(content); + }); + connect(ui->lineEditHost, &QLineEdit::textChanged, m_client, &QMqttClient::setHostname); connect(ui->spinBoxPort, SIGNAL(valueChanged(int)), this, SLOT(setClientPort(int))); updateLogStateChange(); |