Qt Sensors
Qt Sensors 模块通过QML和C++接口提供对传感器硬件的访问。
目前,该 API 支持Android、iOS 和Windows(MSVC)平台。
使用该模块
QML API
可通过 `QtSensors ` 导入语句使用该模块的 QML 类型。要使用这些类型,请在您的 .qml 文件中添加以下导入语句:
import QtSensorsC++ API
要使用 Qt 模块的 C++ API,需要将模块库链接到项目中,既可以直接链接,也可以通过其他依赖项间接链接。包括CMake和qmake 在内的多种构建工具都提供了专门的支持。
使用 CMake 构建
使用find_package() 命令在Qt6 软件包中定位所需的模块组件:
find_package(Qt6 REQUIRED COMPONENTS Sensors)
target_link_libraries(mytarget PRIVATE Qt6::Sensors)更多详细信息,请参阅“使用 CMake 构建”概述。
使用 qmake 构建
要配置模块以便使用 qmake 进行构建,请在项目的 .pro 文件中将该模块作为QT 变量的值添加:
QT += sensors文章与指南
示例
API 参考
模块演变
Qt Sensors列出了针对 Qt 6 系列所做的模块 API 和功能方面的重大变更。
许可与归属
Qt Sensors 模块由The Qt Company 提供商业许可。此外,它还提供自由软件许可:GNU 较少通用公共许可证第 3 版或GNU 通用公共许可证第 2 版。更多详细信息请参阅Qt 许可。
此外,Qt 6.12.0 中的Qt Sensors 可能包含遵循以下宽松许可协议的第三方模块:
Apache 2.0 许可证 |
© 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.