本页内容

QRotationSensor Class

QRotationSensor 类是围绕 `QSensor` 构建的一个便捷封装类。更多内容...

头文件: #include <QRotationSensor>
CMake: find_package(Qt6 REQUIRED COMPONENTS Sensors)
target_link_libraries(mytarget PRIVATE Qt6::Sensors)
qmake: QT += sensors
继承自: QSensor

属性

公共函数

QRotationSensor(QObject *parent = nullptr)
virtual ~QRotationSensor()
bool hasZ() const
QRotationReading *reading() const
void setHasZ(bool hasZ)

信号

void hasZChanged(bool hasZ)

详细说明

唯一的行为差异在于,该类会正确设置类型。

该类还提供了一个reading()函数,该函数返回QRotationReading ,而不是QSensorReading 。

有关传感器工作原理的详细信息,请参阅QRotationReading 。

另请参阅 QRotationReading 。

属性文档

[read-only] hasZ : bool

该属性存储一个值,用于指示 z 角度是否可用。

如果 z 可用,则返回 true;如果 z 不可用,则返回 false。

访问函数:

bool hasZ() const

通知信号:

void hasZChanged(bool hasZ)

成员函数文档

[explicit] QRotationSensor::QRotationSensor(QObject *parent = nullptr)

将该传感器作为parent 的子节点进行构建。

[virtual noexcept] QRotationSensor::~QRotationSensor()

销毁传感器。如果传感器尚未停止运行,则将其停止。

QRotationReading *QRotationSensor::reading() const

返回该传感器的读取类。

另请参阅 QSensor::reading()。

void QRotationSensor::setHasZ(bool hasZ)

设置hasZ 是否可获取z轴角度。该方法应由后端调用。默认情况下,hasZ 属性为true,因此只有当后端的旋转传感器无法报告z轴角度时,才需要调用此方法。

另请参阅 hasZ()。

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