diff options
author | Mate Barany <mate.barany@qt.io> | 2023-06-20 18:14:54 +0200 |
---|---|---|
committer | Mate Barany <mate.barany@qt.io> | 2023-06-26 11:37:28 +0200 |
commit | 770c667325335e7e824463b668d6e3b5bd49e830 (patch) | |
tree | a63db99d5aa001c021c01542d34c5565491525d9 /examples | |
parent | ebd1c795fcc6e0592e508495fcf6b89e0b8d49c4 (diff) |
Revamp documentation for Quicksubscription example
The revamp includes:
- Update the screenshot
- Rename the example
- Add examplecategory : connectivity
- Update the description and snippets to reflect the current
state of the code
Task-number: QTBUG-110893
Change-Id: Id4edd325a539838fb5fa5c6b7fbbbfe4b0c683ce
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/mqtt/doc/images/quicksubscription.png | bin | 14765 -> 15175 bytes | |||
-rw-r--r-- | examples/mqtt/doc/quicksubscription.qdoc | 43 | ||||
-rw-r--r-- | examples/mqtt/doc/simpleclient.qdoc | 2 | ||||
-rw-r--r-- | examples/mqtt/quicksubscription/Main.qml | 2 |
4 files changed, 22 insertions, 25 deletions
diff --git a/examples/mqtt/doc/images/quicksubscription.png b/examples/mqtt/doc/images/quicksubscription.png Binary files differindex bca965b..03ba205 100644 --- a/examples/mqtt/doc/images/quicksubscription.png +++ b/examples/mqtt/doc/images/quicksubscription.png diff --git a/examples/mqtt/doc/quicksubscription.qdoc b/examples/mqtt/doc/quicksubscription.qdoc index b81694f..42e0abd 100644 --- a/examples/mqtt/doc/quicksubscription.qdoc +++ b/examples/mqtt/doc/quicksubscription.qdoc @@ -3,14 +3,15 @@ /*! \example quicksubscription - \title Quick MQTT Example + \title Qt Quick Subscription + \examplecategory {Connectivity} \ingroup qtmqtt-examples - \brief Registering QMqttClient to QML and using it in a Qt Quick user - interface. + \brief Use Qt Quick Controls to create an application that can subscribe to MQTT + topics. \image quicksubscription.png - \e {Quick MQTT} demonstrates how to register QMqttClient as a QML type and + \e {Qt Quick Subscription} 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, @@ -18,23 +19,24 @@ \section1 Creating a Client - We create a \c QmlMqttClient class with the QMqttClient class as a base - class: + Connect to QMqttSubscription::messageReceived( ) to receive all messages + sent to the broker: \quotefromfile quicksubscription/qmlmqttclient.cpp - \skipto QmlMqttClient( + \skipto QmlMqttSubscription \printuntil } - We use the \c subscribe() function to create a subscription object: + Create a \c QmlMqttClient class with the QMqttClient class as a base + class: + \skipto QmlMqttClient( \printuntil } - We connect to QMqttSubscription::messageReceived( ) to receive all messages - sent to the broker: - + Use the \c subscribe() function to create a subscription object: + \skipto subscribe \printuntil } - We use an QMqttMessage object to store the payload of a received + Use a QMqttMessage object to store the payload of a received message: \skipto handleMessage @@ -42,22 +44,17 @@ \section1 Registering Classes in QML - In the \c main.cpp file, we register the \c QmlMqttClient class as a - QML type, MqttClient: + In the \c main.cpp file, load the QML type Main from the module + subscription: \quotefromfile quicksubscription/main.cpp - \skipto main(int - \printuntil qmlRegisterType - - In addition, we register the \c QmlMqttSubscription class as an uncreatable - type: - - \printuntil qmlRegisterUncreatableType + \skipto (argc + \printuntil loadFromModule - We can now use the MqttClient type in the \c main.qml file to create an + Now use the MqttClient type in the \c Main.qml file to create an MQTT client: - \quotefromfile quicksubscription/main.qml + \quotefromfile quicksubscription/Main.qml \skipto MqttClient { \printuntil } */ diff --git a/examples/mqtt/doc/simpleclient.qdoc b/examples/mqtt/doc/simpleclient.qdoc index aecd4ce..a4e26ef 100644 --- a/examples/mqtt/doc/simpleclient.qdoc +++ b/examples/mqtt/doc/simpleclient.qdoc @@ -52,5 +52,5 @@ \l {MQTT Subscriptions} example. For an example of how to use the QMqttClient class in a Qt Quick - application, see \l {Quick MQTT Example}. + application, see \l {Qt Quick Subscription}. */ diff --git a/examples/mqtt/quicksubscription/Main.qml b/examples/mqtt/quicksubscription/Main.qml index df3f646..7f9be5a 100644 --- a/examples/mqtt/quicksubscription/Main.qml +++ b/examples/mqtt/quicksubscription/Main.qml @@ -10,7 +10,7 @@ Window { visible: true width: 640 height: 480 - title: qsTr("Qt Quick MQTT Subscription Example") + title: qsTr("Qt Quick Subscription") id: root property var tempSubscription: 0 |