Qt Sensors

The Qt Sensors module provides access to sensor hardware via QML and C++ interfaces.

Currently, the API is supported on Android , iOS ,和 Windows (MSVC) .

使用模块

QML API

The QML types of the module are available through the QtSensors 导入。要使用类型,添加以下 import 语句到 .qml 文件:

import QtSensors
					

C++ API

Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake .

构建采用 CMake

使用 find_package() command to locate the needed module component in the Qt6 包:

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

更多细节,见 构建采用 CMake 概述。

采用 qmake 构建

To configure the module for building with qmake, add the module as a value of the QT variable in the project's .pro file:

QT += sensors
					

文章和指南

范例

API 参考

Module Evolution

Changes to Qt Sensors lists important changes in the module API and functionality that were made for the Qt 6 series of Qt.

许可

The Qt Sensors module is available under commercial licenses from Qt 公司 . In addition, it is available under free software licenses: The GNU LGPL (次一般公共许可) 第 3 版 ,或 GNU GPL (一般公共许可) 第 2 版 。见 Qt 许可 进一步了解细节。