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 由The Qt Company 提供商业许可。此外,该软件还遵循GNU 通用公共许可证第 3 版。
© 2026 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.