Qt Sensors

Qt Sensors 模块通过 QML 和 C++ 接口访问传感器硬件。

目前,该应用程序接口支持AndroidiOSWindows (MSVC)

使用模块

QML API

模块的 QML 类型可通过QtSensors import 获取。要使用这些类型,请在 .qml 文件中添加以下导入语句:

import QtSensors

C++ API

使用 Qt 模块的 C++ API 需要直接或通过其他依赖关系与模块库链接。一些编译工具对此提供了专门支持,包括CMakeqmake

使用 CMake 构建

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

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

更多详情,请参阅使用 CMake 构建概述。

使用 qmake 构建

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

QT += sensors

文章和指南

示例

应用程序接口参考

模块演变

Qt Sensors 的变更列出了 Qt 6 系列 Qt 在模块 API 和功能方面的重要变更。

许可和归属

Qt Sensors 模块可在Qt Company 的商业许可下使用。此外,它还受自由软件许可证的保护:GNU 宽通用公共许可证第 3 版GNU 通用公共许可证第 2 版。详情请参见Qt Licensing

此外,Qt 6.9.0 中的Qt Sensors 可能包含以下许可下的第三方模块:

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