本页面

Qt Serial Port

Qt Serial Port 提供了用于 RS-232 引脚布局的配置、I/O 操作以及控制信号的获取和设置等基本功能。

本模块不支持以下功能:

  • 终端功能,例如回显、CR/LF控制等。
  • 用于数据传输的文本模式显示。
  • 读写操作时的超时和延迟配置。
  • 引脚信号变化的通知。

模块的使用

要使用 Qt 模块的 C++ API,需要与模块库进行链接,可以是直接链接,也可以是通过其他依赖项间接链接。一些构建工具对此提供了专门的支持,包括CMake和qmake。

使用 CMake 构建

使用find_package() 命令在Qt6 软件包中定位所需的模块组件:

find_package(Qt6 REQUIRED COMPONENTS SerialPort)
target_link_libraries(mytarget PRIVATE Qt6::SerialPort)

更多详细信息,请参阅“使用 CMake 构建”概述。

使用 qmake 构建

要配置模块以便使用 qmake 进行构建,请在项目的 .pro 文件中将该模块作为QT 变量的值添加:

QT += serialport

模块演变

Qt SerialPort 的变更列出了为 Qt 6 系列所做的模块 API 和功能方面的重大变更。

许可

Qt SerialPort 由The Qt Company 提供商业许可。此外,它还遵循GNU 较少通用公共许可证(第 3 版)或GNU 通用公共许可证(第 2 版)发布。更多详细信息请参阅Qt 许可。

© 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.