QSensorReading Class

QSensorReading class holds the readings from the sensor. 更多...

头: #include <QSensorReading>
qmake: QT += sensors
继承: QObject
继承者:

QAccelerometerReading , QAltimeterReading , QAmbientLightReading , QAmbientTemperatureReading , QCompassReading , QDistanceReading , QGyroscopeReading , QHolsterReading , QHumidityReading , QIRProximityReading , QLidReading , QLightReading , QMagnetometerReading , QOrientationReading , QPressureReading , QProximityReading , QRotationReading , QTapReading ,和 QTiltReading

特性

公共函数

void setTimestamp (quint64 timestamp )
quint64 timestamp () const
QVariant value (int index ) const
int valueCount () const

DECLARE_READING ( classname )
IMPLEMENT_READING ( classname )

额外继承成员

详细描述

QSensorReading class holds the readings from the sensor.

注意, QSensorReading is not particularly useful by itself. The interesting data for each sensor is defined in a sub-class of QSensorReading .

特性文档编制

timestamp : const quint64

This property holds the timestamp of the reading.

Timestamps values are microseconds since a fixed point. You can use timestamps to see how far apart two sensor readings are.

Note that sensor timestamps from different sensors may not be directly comparable (as they may choose different fixed points for their reference).

Note that some platforms do not deliver timestamps correctly . Applications should be prepared for occasional issues that cause timestamps to jump backwards.

访问函数:

quint64 timestamp () const

成员函数文档编制

void QSensorReading:: setTimestamp ( quint64 timestamp )

设置 timestamp of the reading.

另请参阅 timestamp ().

quint64 QSensorReading:: timestamp () const

Returns the timestamp of the reading.

注意: Getter 函数对于特性 timestamp .

另请参阅 setTimestamp ().

QVariant QSensorReading:: value ( int index ) const

Returns the value of the property at index .

Note that this function is slower than calling the data function directly.

Here is an example of getting a property via the different mechanisms available.

Accessing directly provides the best performance but requires compile-time knowledge of the data you are accessing.


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

You can also access a property by name. To do this you must call QObject::property ().


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

Finally, you can access values via numeric index.


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

Note that value() can only access properties declared with Q_PROPERTY () in sub-classes of QSensorReading .

另请参阅 valueCount () 和 QObject::property ().

int QSensorReading:: valueCount () const

Returns the number of extra properties that the reading has.

Note that this does not count properties declared in QSensorReading .

As an example, this returns 3 for QAccelerometerReading because there are 3 properties defined in that class.

宏文档编制

DECLARE_READING ( classname )

The DECLARE_READING macro adds some required methods to a reading class.

This macro should be used for all reading classes. Pass the classname of your reading class.


  class MyReading : public QSensorReading
  {
      Q_OBJECT
      Q_PROPERTY(qreal myprop READ myprop)
      DECLARE_READING(MyReading)
  public:
      qreal myprop() const;
      vod setMyprop(qreal myprop);
  };
					

另请参阅 IMPLEMENT_READING ().

IMPLEMENT_READING ( classname )

The IMPLEMENT_READING macro implements the required methods for a reading class.

This macro should be used for all reading classes. It should be placed into a single compilation unit (source file), not into a header file. Pass the classname of your reading class.


  IMPLEMENT_READING(MyReading)
					

另请参阅 DECLARE_READING ().