PySide6.QtSensors.QSensorReading

class QSensorReading

QSensorReading 类保存来自传感器的读数。更多

PySide6.QtSensors.QSensorReading 的继承图

继承自: QTiltReading, QTapReading, QRotationReading, QProximityReading, QPressureReading, QOrientationReading, QMagnetometerReading, QLightReading, QLidReading, QIRProximityReading, QHumidityReading, QGyroscopeReading, QCompassReading, QAmbientTemperatureReading, QAmbientLightReading, QAccelerometerReading

概要

属性

方法

虚拟方法

注意

本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。

详细描述

请注意,QSensorReading 本身并不是特别有用。每个传感器的有趣数据在 QSensorReading 的子类中定义。

注意

当使用from __feature__ import true_property时,属性可以直接使用,否则通过访问器函数使用。

property timestampᅟ: int

此属性保存读取的时间戳。

时间戳值是从一个固定点开始的微秒数。您可以使用时间戳来查看两个传感器读数之间的间隔有多远。

请注意,来自不同传感器的传感器时间戳可能无法直接比较(因为它们可能选择不同的固定点作为参考)。

请注意,某些平台无法正确传递时间戳。应用程序应准备好应对偶尔导致时间戳跳回的问题。

Access functions:
copyValuesFrom(other)
Parameters:

其他QSensorReading

setTimestamp(timestamp)
Parameters:

timestamp – int

设置读取的timestamp

另请参阅

timestamp()

timestamp()
Return type:

整数

返回读取的时间戳。

另请参阅

setTimestamp()

属性 timestampᅟ 的获取器。

value(index)
Parameters:

索引 – int

Return type:

对象

返回位于index处的属性值。

请注意,此函数比直接调用数据函数要慢。

这里是一个通过不同可用机制获取属性的示例。

直接访问提供了最佳性能,但需要编译时了解您正在访问的数据。

QAccelerometerReading *reading = ...;
qreal x = reading->x();

你也可以通过名称访问属性。为此,你必须调用 QObject::property()。

qreal x = reading->property("x").value<qreal>();

最后,您可以通过数字索引访问值。

qreal x = reading->value(0).value<qreal>();

请注意,value() 只能访问在 QSensorReading 的子类中使用 Q_PROPERTY() 声明的属性。

另请参阅

valueCount() property()

valueCount()
Return type:

整数

返回读数中额外属性的数量。

请注意,这不包括在QSensorReading中声明的属性。

例如,对于QAccelerometerReading,这将返回3,因为该类中定义了3个属性。