1
0
mirror of https://github.com/qt/qtmqtt.git synced 2026-10-25 16:16:26 +00:00
Commit Graph

97 Commits

Author SHA1 Message Date
Jerome Pasion
34656ac5ba Doc: Add alt text for \image tags for qtmqtt
Alternate text (alt text) improves the documentation experience for
screen readers and for other accessibility tools.

Task-number: QTBUG-135098
Pick-to: 6.11
Change-Id: Ia1793ff3e0bacd8cfdad2e8c04725a5093ed30aa
Reviewed-by: David Boddie <david.boddie@qt.io>
2026-03-11 14:32:53 +01:00
Even Oscar Andersen
6eb01cac46 Mention in websockets subscription example that websockets are builtin
Added a \note, but keeping the example to show how to create custom
transports.

Pick-to: 6.10
Change-Id: Idf3b22532f6e0b94a0113cea6152a36e81398ea9
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-06-12 13:40:32 +02:00
Even Oscar Andersen
dec643fc61 Add websocket support for mqtt
Move the example IODevices to be used with websockets
under the mqtt umbrella.

Two (private) devices are created; QMqttSecureWebSocketIO
and QMqttWebSocketIO

Fixes: QTBUG-129171
Change-Id: Ib7d37150c3a229e882a0c04a32cdd8b7929baf3b
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
2025-01-29 07:42:34 +01:00
Even Oscar Andersen
b539b0c38b Fix signal/slot problem with quicksubscription example
The example does not build with latest changes.

As it turns out there is a mismatch between the topic property
and the connected signal. Since the signal is not used, it is
removed in the hope that it will then build.

The error message from the build is:

Failure Summary:
The build failed due to a compilation error in 'qmlmqttclient.cpp'.
The function 'QmlMqttSubscription::topicChanged()' was called without
the required 'QString' argument.

Log snippet:
error: no matching function for call to ‘QmlMqttSubscription::topicChanged()’
note: candidate: ‘void QmlMqttSubscription::topicChanged(QString)’
note: candidate expects 1 argument, 0 provided

Change-Id: Ia8cedda578e2f2c082354892bd00cb9fd25b5652
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-11-20 17:36:32 +01:00
Lucie Gérard
9e1a2c5287 Change license for build files in example
According to QUIP-18 [1], all example files should be
LicenseRef-Qt-Commercial OR BSD-3-Clause

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: I1133ca3b2daf487dbbc2ddae6b94d7f20239ed49
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-03-20 08:12:04 +01:00
Tim Blechmann
7fd54b4961 examples: silence clang's wignored-qualifier
Change-Id: Ibdefee544ced86db73bbf821ea8c62c0d8c5c043
Pick-to: 6.7
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2024-02-02 00:08:29 +00:00
Mate Barany
1f9e2bf463 Remove redundant call from QuickPublication Example
Remove the call m_client.state(), it seems to be unnecessary (just like
in the Quicksubscription example).

Pick-to: 6.6 6.5
Task-number: QTBUG-110893
Change-Id: I460f12f3d4b33388013cb8250149239a6b0f1c94
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-06-26 14:42:43 +02:00
Mate Barany
87223c466a Document the Quickpublication example
Provide the missing documentation for the Quickpublication example

Task-number: QTBUG-110893
Change-Id: I002208e2e036a09acd68621f075bed7a11b6598f
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2023-06-26 12:59:23 +02:00
Mate Barany
770c667325 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>
2023-06-26 11:37:28 +02:00
Mate Barany
ebd1c795fc Remove m_client.state() call from QmlMqttClient::setPort
Remove m_client.state() call from QmlMqttClient::setPort, it seems to
be unnecessary.

Pick-to: 6.6 6.5
Task-number: QTBUG-110893
Change-Id: I4e1d8d2daf16da6c588f1b0b339ea863a22b32c0
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-06-20 14:07:00 +02:00
Mate Barany
a6581736ff QuickPublication Example: fix qmllint warnings
Fix the qmllint warnings in the quickpublication example.

Pick-to: 6.6 6.5
Task-number: QTBUG-110893
Change-Id: If78a908807ee8a5f6f693d159a05a9ee91b1e38d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-06-20 13:53:31 +02:00
Mate Barany
f49eaa9b7a QuickPublication Example: Remove version numbers from imports
Remove the version numbers according to revamp the guideline.

Pick-to: 6.6 6.5
Task-number: QTBUG-110893
Change-Id: I9e8fdd0fa54b3218efd2c55bd3dac3137d43e756
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2023-06-20 13:35:12 +02:00
Mate Barany
63b5119a3e QuickPublication example: Port CMakeLists.txt to use qt_add_qml_module
Port the CmakeLists.txt and change the source files accordingly:
- rename main.qml to Main.qml
- remove MqttClient import from Main.qml
- add QML macros to qmlmqttclient.h
- revamp main.cpp

Also update the qmake build:
- revamp quickpublication.pro
- add qmldir to project
- remove qml.qrc

Pick-to: 6.6 6.5
Task-number: QTBUG-110893
Change-Id: Iffe3e80e40f318d1520ca108933760c0e5d0c18a
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-06-20 11:33:02 +02:00
Mate Barany
6e3f752fc4 QuickSubscription Example: fix qmllint warnings
Fix the qmllint warnings in the quicksubscription example.

Pick-to: 6.6 6.5
Task-number: QTBUG-110893
Change-Id: I4f633573b8c8f28eb65d7d4a57d4a63d8b7f5881
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-06-20 10:39:45 +02:00
Mate Barany
3cef85357d QuickSubscription Example: Remove version numbers from imports
Remove the version numbers according to the guideline

Task-number: QTBUG-110893
Change-Id: I5e1bf98a6180be039f385a8e4376dcd01df2e8c4
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2023-06-13 09:56:33 +02:00
Mate Barany
03cc0dd512 QuickSubscription example: Port CMakeLists.txt to use qt_add_qml_module
Port the CmakeLists.txt and change the source files accordingly:
- rename main.qml to Main.qml
- remove MqttClient import from Main.qml
- add QML macros to qmlmqttclient.h
- revamp main.cpp

Also update the qmake build:
- revamp quicksubscription.pro
- add qmldir to project
- remove qml.qrc

Pick-to: 6.6 6.5
Task-number: QTBUG-110893
Change-Id: Ie7c0dd260e94c1e1ad4756fb21a70f24f2c60f87
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-12 09:58:14 +02:00
Mate Barany
1ba0938e80 Use the list initializer constructor of QStringList
Use the list initializer constructor of QStringList to make the code
more modern/compact.

Task-number: QTBUG-110893
Change-Id: Idf1cfb400e19cad87b70a40735fa17c87cf7fb30
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-06-07 15:48:41 +02:00
Mate Barany
8fc1b0de9d Replace QLatin1Strings with _L1 literals
As part of revamping the MQTT examples, replace QLatin1Strings with
_L1 literals.

Also replace QLatin1Chars and QStringLiterals with the appropriate
u'' and u""_s literals.

Task-number: QTBUG-110893
Change-Id: I784f5faa23e51666b6edf36eb9692c0f7c186f70
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-06-07 15:34:39 +02:00
Chris Adams
c9c49bdf47 Examples: websocket IO device must be sequential
When using a websocket as the underlying IO device we must specify
that the device is sequential, to avoid spurious protocol violation
condition when packets are split across websocket frame boundaries.

The standard specifically states: "The receiver MUST NOT assume that
MQTT Control Packets are aligned on WebSocket frame boundaries."
New MQTT brokers like FlashMQ rely on well-behaved receivers.

Change-Id: Ia8e7fb0cf1cc518b364625b1955fb6b9ee44b7ef
Pick-to: 6.5
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2023-05-26 06:23:14 +00:00
Mate Barany
e96f355983 Revamp documentation of the Websockets MQTT Subscription Example
Remove "Example" from the name of the example.

Add examplecategory.

Add a short explanation and a few code snippets.

Task-number: QTBUG-110893
Change-Id: I0e4e29b9cd86c4950fdd0263ecec54e8927b2c3c
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2023-05-23 17:20:05 +02:00
Mate Barany
84e3561bf8 Fix some compiler warnings in the MQTT WebsocketSubscription Example
Fix some warnings that were reported by the MSVC compiler with the Wall
setting:
- use static_cast for signed/unsigned conversion
- use QString::fromUtf8 instead of the QByteArray constructor

Pick-to: 6.5
Task-number: QTBUG-110893
Change-Id: Ic982d3c16feb1ebcef729b4dfd023cc3b5017fec
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2023-04-27 16:14:49 +02:00
Mate Barany
816cedb719 Rename MQTT Simple Client example and update screenshot
Remove the word "Example" from the name of the example.

Add the example to the "Connectivity" Category.

Update the screenshot - the example no longer has a ping button.

Task-number: QTBUG-110893
Change-Id: Ieedb32800804fc336ba0e3bd0c8f3b9e4cd13527
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-04-24 16:01:27 +02:00
Mate Barany
9925e316c9 Fix compiler warnings in Simple Client example
Fix some signed/unsigned conversion warnings in the Simple Client
example reported by Visual Studio with the Wall compiler settings.

Pick-to: 6.5
Task-number: QTBUG-110893
Change-Id: I0a1851098d314c63195eb2366a6f87f42a4bbed4
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2023-04-20 15:20:10 +02:00
Mate Barany
9e8dbb1509 Fix compiler warnings in MQTT Subscription Example
Fix some signed/unsigned conversion warnings.

Add explicit QMqttSubscription::Unsubscription case.

These warnings were reported by Visual Studio with the Wall compiler
setting.

Pick-to: 6.5
Task-number: QTBUG-110893
Change-Id: Ief64c4a04ba679f52c3e256aa96bb8f239ae68e9
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2023-04-20 14:57:45 +02:00
Mate Barany
1c522a09b2 Rename MQTT Subscriptions Example and update screenshot
According to the guideline "Example" should be not part of the name of
the example - remove it.

Add example to the Connectivity category.

Update the screenshot as the current one is obsolete. The application
no longer has a ping button but it has username and password fields.

Task-number: QTBUG-110893
Change-Id: Id9608ea6e76a3a7e89b0fd491d9fb329cfcbedc3
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-04-20 08:50:41 +00:00
Mate Barany
447db4134b Move the console pub/sub example to manual tests
The example is not documented and it is also missing from the
examples-manifest.xml file. However, it can be still useful
for debugging or for performing small tests, so move it to
the tests/manual folder.

The qmake project files are kept for the examples because the
CI builds the examples with CMake and qmake. Now that this has
been moved to tests/manual, the .pro files can be removed.

Change-Id: Id69c3c6896d98b543ff5bd493592d06a27746496
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2023-04-01 10:02:50 +02:00
Mårten Nordheim
e823268419 Update websocket example to use the new sub-protocol feature
This also fixes the example, which was erroring out when
the server picked a sub-protocol due to a bug in QWebSocket

Pick-to: 6.4
Task-number: QTBUG-108276
Change-Id: I582facd79bb5af7e068941d59e2d44b57a39aebc
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-11-22 12:35:31 +01:00
Maurice Kalinowski
d26a01b1a6 Reimplement QmlMqttClient
QMqttClient is not meant to be directly exported to QML. One reason is
that it uses quint16 for port declaration to minimize size of the class.
However, that is not properly handled on all platforms for the QML
engine.

Instead create a proper wrapper for the client and only expose required
elements.

Fixes: QTBUG-80440
Pick-to: 6.4
Change-Id: Id4066ce24338b0270af05b06c6216c1755dab533
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2022-10-23 19:14:51 +02:00
Lucie Gérard
3012258ec3 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I9caf6ad52cd6a0a63ce7ff37ce189ec4b368befd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2022-08-23 10:00:53 +02:00
Ivan Solovev
241b27ff88 Use QT_DISABLE_DEPRECATED_UP_TO instead of QT_DISABLE_DEPRECATED_BEFORE
Task-number: QTBUG-104944
Change-Id: I98c2a652abb366354710b57e2fea7eb22235c66f
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-22 12:59:53 +02:00
Lucie Gérard
d431a18c5c Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I40135f08b4e89e8e034ec764ffed3273fc60646a
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2022-07-07 10:10:51 +02:00
Lucie Gérard
edd6855344 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: Ie4309963c8e17d4e7dad602f61a660246d5e23cb
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-16 10:22:20 +02:00
Kai Köhne
39b18224f5 Remove .prev_CMakeLists.txt
Pick-to: 6.3
Change-Id: I9f95857b917047b85936a651ece9a30a6f64d019
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2022-03-23 11:01:37 +01:00
Kai Köhne
b3f44d87a7 Improve examples CMakeLists.txt
- Remove '# generated from xyz.pro' comment from pro2cmake
- Remove automatic use of CMAKE_AUTORCC
- Only opt into CMAKE_AUTOUIC if .ui files are involved
- Remove explicit setting of CMAKE_INCLUDE_CURRENT_DIR
- Combine multiple find_package(Qt6 ... calls)
 - use REQUIRED COMPONENTS
 - sort components alphabetically
- Fix wrong indentations
- Use (only) one empty line after multi-line commands

Pick-to: 6.3
Change-Id: Idf2f3d5a09a496fa5c578bbeae84f3560549f1a9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-21 10:25:12 +01:00
Alexandru Croitor
fe375a0ff2 Switch examples to build as isolated sub-builds part 2
qt_examples_build_begin needs the EXTERNAL_BUILD flag
to know that it's safe to build examples as ExternalProjects.

It still won't do it in CI until we enable building
examples as ExternalProjects for prefix builds.

This is preparation for that.

Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Change-Id: If3e2e42c6a1540cf1c7e80bc7c3f3dfc28ee40eb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-05 01:34:55 +01:00
Alexandru Croitor
ca62c67daf Switch examples to build as isolated sub-builds
Pick-to: 6.2 6.3
Task-number: QTBUG-90820
Change-Id: I8075a81431b71d0dd65b2fadce4c24a8a43e63b3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-15 11:08:08 +01:00
Joerg Bornemann
115357fbae Raise cmake_minimum_required to VERSION 3.16 in examples
Pick-to: 6.2
Task-number: QTBUG-95636
Change-Id: I821f412f9dbe11ae99ffd888a7ab2ba415ed9379
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 13:48:20 +02:00
Joerg Bornemann
f9ebebfce7 CMake: Disable usage of CMake API compatibility wrappers
Setting the QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS variable
in the project ensures we ported away from old API calls.

Task-number: QTBUG-86815
Change-Id: I589f0192370a932ac10088656eaee1e35a41ea73
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-26 21:04:15 +02:00
Alexandru Croitor
5ea20cc458 CMake: Regenerate projects
And use an updated coin instruction file.

Change-Id: I852d38febe9ecaa86c516b7f4a0451d0f80d8011
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-05-26 17:43:51 +02:00
Alexandru Croitor
a450023285 Merge remote-tracking branch 'origin/wip/cmake' into dev
Change-Id: I5074da47986bcc826d3990238b02ebe7e6cc3d2e
2020-05-26 17:38:47 +02:00
Maurice Kalinowski
07b7baf3ca Regenerate projects
Change-Id: I8b306c077030ffe1904d42f813f3b7cacc35a0c9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-05-26 15:23:16 +00:00
Qt Forward Merge Bot
68904322f6 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	.qmake.conf

Change-Id: Id9db3547396bd82b170db8c3025e5060d4cbba3e
2020-01-13 09:34:56 +01:00
Maurice Kalinowski
c279feb00c Fix build with --no-widgets
Apparently a new configuration in our CI.

Fixes: QTBUG-81064
Task-number: QTQAINFRA-2576
Change-Id: I022b56fd4fae487dfb84041c30ce061a28e5484c
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2020-01-03 11:03:14 +01:00
Maurice Kalinowski
e94f0e150a Fix flaky installation
In very few cases, the installation step for the console
example might copy the configuration.h header of both
subprojects concurrently. In that case Mac bails out with an
error.
Avoid this by iterating ordered.

Change-Id: Ic9dde91b1200a04ae598210f8b432d6efdd5d5c8
Fixes: QTBUG-80363
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2019-12-02 12:58:41 +01:00
Alexandru Croitor
113f7ee864 Regenerate projects
Change-Id: I7574a6156e4c340ba94007176287a5d1bcb7f9e1
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-15 13:02:47 +00:00
Maurice Kalinowski
450f2b3dd3 Examples: Remove ping buttons
Since dcf3bbb980 introduced
autoKeepAlive, users should not send a ping message manually
unless it is disabled.

Change-Id: I4b717e2aebc8f40cabf009d4df7e1d146988d434
Fixes: QTBUG-79444
Reviewed-by: hjk <hjk@qt.io>
2019-10-24 16:36:06 +02:00
Maurice Kalinowski
e7d71199ff Use nullptr instead of 0
Change-Id: Id4c8b194ce8ff8ec94fafcf1169a0cc9717684ed
Reviewed-by: hjk <hjk@qt.io>
2019-10-24 15:12:45 +02:00
Maurice Kalinowski
4e4050fdbd Update usage for encrypted connection
Use the QMqttClient::connectToHostEncrypted() version taking a
QSslConfiguration instead of applying global settings.
Furthermore, the deprecated version will be removed in Qt6.

Change-Id: I4b2a9ff2616ed1c0c645d0081719f2d40c6e3b20
Reviewed-by: hjk <hjk@qt.io>
2019-09-26 12:45:22 +02:00
Maurice Kalinowski
4e5af443ef Add initial support for cmake
Change-Id: I40153b0f225d67afebfaf3ff0b1c43a9c2f69b8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-02 07:06:48 +00:00
Liang Qi
91cefe7217 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	.qmake.conf
	examples/mqtt/mqtt.pro

Change-Id: Ic76ff03e314e0d9761ba66372e19f546afcc7d6c
2019-06-28 10:25:49 +02:00