Qt MQTT
MQTT是一种利用发布和订阅模式的机器对机器(M2M)协议。其目的是提供一个通信开销最小的通道。
一般来说,MQTT 是在 TCP 连接之上使用的。不过,基本要求被定义为有序、无损、双向连接。
Qt MQTT 模块提供了 MQTT 协议规范的标准兼容实施。它能让应用程序充当遥测显示器,让设备发布遥测数据。支持的版本有 MQTT 3.1、MQTT 3.1.1 和 MQTT 5.0。
使用模块
使用 Qt 模块需要直接或通过其他依赖关系与模块库链接。有几种构建工具专门为此提供支持,包括CMake和qmake。
使用 CMake 构建
使用find_package()
命令在Qt6
软件包中找到所需的模块组件:
find_package(Qt6 REQUIRED COMPONENTS Mqtt) target_link_libraries(mytarget PRIVATE Qt6::Mqtt)
另请参阅使用 CMake 构建概述。
使用 qmake 构建
要配置使用 qmake 构建的模块,请在项目的 .pro 文件中添加模块作为QT
变量的值:
QT += mqtt
文章和指南
示例
参考资料
许可证和归属
Qt MQTT 可通过Qt 公司的商业许可证获取。此外,它还受GNU 通用公共许可证第 3 版的保护。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.