diff options
author | Leena Miettinen <riitta-leena.miettinen@qt.io> | 2017-10-25 14:01:20 +0200 |
---|---|---|
committer | Leena Miettinen <riitta-leena.miettinen@qt.io> | 2017-11-08 08:47:29 +0000 |
commit | 10d8fb1fefc99c4e3ec003788793a47b525917d8 (patch) | |
tree | 1d56ece3e30a55c7727a25a1be1f21335195aff6 /examples | |
parent | 6d4ca0a999d18f6f8e01afa9762ae3e77eac71db (diff) |
Doc: Add screenshot and details to Qt MQTT example docs
Change-Id: Ib3f1eaac6bc09ee40ea0244c3445eee354f0d965
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/mqtt/doc/images/quicksubscription.png | bin | 0 -> 14765 bytes | |||
-rw-r--r-- | examples/mqtt/doc/quicksubscription.qdoc | 53 |
2 files changed, 49 insertions, 4 deletions
diff --git a/examples/mqtt/doc/images/quicksubscription.png b/examples/mqtt/doc/images/quicksubscription.png Binary files differnew file mode 100644 index 0000000..bca965b --- /dev/null +++ b/examples/mqtt/doc/images/quicksubscription.png diff --git a/examples/mqtt/doc/quicksubscription.qdoc b/examples/mqtt/doc/quicksubscription.qdoc index 833136b..86cdf2f 100644 --- a/examples/mqtt/doc/quicksubscription.qdoc +++ b/examples/mqtt/doc/quicksubscription.qdoc @@ -55,11 +55,56 @@ \brief Registering QMqttClient to QML and using it in a Qt Quick user interface. - \e {Quick MQTT} demonstrates how to register QMqttClient to QML and use it - in a Qt Quick user interface + \image quicksubscription.png + + \e {Quick MQTT} demonstrates how to register QMqttClient as a QML type and + use it in a Qt Quick application. \l {Qt MQTT} does not provide a QML API in its current version. However, - making the C++ classes of the module available to QML is very easy and - described in this example. + you can make the C++ classes of the module available to QML. + + \section1 Creating a Client + + We create a \c QmlMqttClient class with the QMqttClient class as a base + class: + + \quotefromfile quicksubscription/qmlmqttclient.cpp + \skipto QmlMqttClient( + \printuntil } + + We use the \c subscribe() function to create a subscription object: + + \printuntil } + + We connect to QMqttSubscription::messageReceived( ) to receive all messages + sent to the broker: + + \printuntil } + + We use an QMqttMessage object to store the payload of a received + message: + + \skipto handleMessage + \printuntil } + + \section1 Registering Classes in QML + + In the \c main.cpp file, we register the \c QmlMqttClient class as a + QML type, MqttClient: + + \quotefromfile quicksubscription/main.cpp + \skipto main(int + \printuntil qmlRegisterType + + In addition, we register the \c QmlMqttSubscription class as an uncreatable + type: + + \printuntil qmlRegisterUncreatableType + + We can now use the MqttClient type in the \c main.qml file to create an + MQTT client: + \quotefromfile quicksubscription/main.qml + \skipto MqttClient { + \printuntil } */ |