The QSensorReading class holds the readings from the sensor. More...
|CMake:|| find_package(Qt6 REQUIRED COMPONENTS Sensors) |
target_link_libraries(mytarget PRIVATE Qt6::Sensors)
|qmake:||QT += sensors|
|Inherited By:|| |
QAccelerometerReading, QAmbientLightReading, QAmbientTemperatureReading, QCompassReading, QGyroscopeReading, QHumidityReading, QLightReading, QMagnetometerReading, QOrientationReading, QPressureReading, QProximityReading, QRotationReading, and QTiltReading
- List of all members, including inherited members
- QSensorReading is part of sensors_main.
- timestamp : const quint64
|QVariant||value(int index) const|
Note that QSensorReading is not particularly useful by itself. The interesting data for each sensor is defined in a sub-class of QSensorReading.
[read-only] 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.
Member Function Documentation
void QSensorReading::setTimestamp(quint64 timestamp)
Sets the timestamp of the reading.
See also timestamp().
quint64 QSensorReading::timestamp() const
Returns the timestamp of the reading.
Note: Getter function for property timestamp.
See also 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.
You can also access a property by name. To do this you must call QObject::property().
Finally, you can access values via numeric index.
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.
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.
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.
See also DECLARE_READING().
© 2022 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.