The QSensorReading class holds the readings from the sensor. More...
#include <QSensorReading>
Inherits: QObject.
Inherited by: QAccelerometerReading, QAmbientLightReading, QCompassReading, QGyroscopeReading, QLightReading, QMagnetometerReading, QOrientationReading, QProximityReading, QRotationReading, and QTapReading.
This class was introduced in Qt Mobility 1.0.
void | setTimestamp ( qtimestamp timestamp ) |
qtimestamp | timestamp () const |
QVariant | value ( int index ) const |
int | valueCount () const |
DECLARE_READING ( classname ) | |
IMPLEMENT_READING ( classname ) |
The QSensorReading class holds the readings from the sensor.
Note that QSensorReading is not particularly useful by itself. The interesting data for each sensor is defined in a sub-class of QSensorReading.
This property holds the timestamp of the reading.
This property was introduced in Qt Mobility 1.0.
Access functions:
qtimestamp | timestamp () const |
See also qtimestamp.
Sets the timestamp of the reading.
This function was introduced in Qt Mobility 1.0.
See also timestamp().
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.
This function was introduced in Qt Mobility 1.0.
See also valueCount() and QObject::property().
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.
This function was introduced in Qt Mobility 1.0.
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); };
See also IMPLEMENT_READING().
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)
See also DECLARE_READING().
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.