The QMagnetometerReading class represents one reading from the magnetometer. 更多...
头: | #include <QMagnetometerReading> |
qmake: | QT += sensors |
Since: | Qt 5.1 |
继承: | QSensorReading |
QMagnetometerReading (QObject * parent = DECLARE_READING(QMagnetometerReading)) | |
virtual | ~QMagnetometerReading () |
qreal | calibrationLevel () const |
void | setCalibrationLevel (qreal calibrationLevel ) |
void | setX (qreal x ) |
void | setY (qreal y ) |
void | setZ (qreal z ) |
qreal | x () const |
qreal | y () const |
qreal | z () const |
virtual void | copyValuesFrom (QSensorReading * other ) override |
const QMetaObject | staticMetaObject |
The QMagnetometerReading class represents one reading from the magnetometer.
The magnetometer returns magnetic flux density values along 3 axes. The scale of the values is teslas. The axes are arranged as follows.
The magnetometer can report on either raw magnetic flux values or geomagnetic flux values. By default it returns raw magnetic flux values. The QMagnetometer::returnGeoValues property must be set to return geomagnetic flux values.
The primary difference between raw and geomagnetic values is that extra processing is done to eliminate local magnetic interference from the geomagnetic values so they represent only the effect of the Earth's magnetic field. This process is not perfect and the accuracy of each reading may change.
The image below shows the difference between geomagnetic (on the left) and raw (on the right) readings for a phone that is being subjected to magnetic interference.
The accuracy of each reading is measured as a number from 0 to 1. A value of 1 is the highest level that the device can support and 0 is the worst.
If the device is reporting low accuracy, then calibration might be needed before acceptable measurements can be provided. Basic calibration can usually be done by either rotating your device in a figure of eight, or by rotating the device along each of its three axes. For more information, check your device's documentation on how to calibrate the magnetic sensor.
This property holds the accuracy of the reading.
度量值从 0 到 1,更高值更佳。
Note that this only changes when measuring geomagnetic flux density. Raw magnetic flux readings will always have a value of 1.
访问函数:
qreal | calibrationLevel () const |
另请参阅 QMagnetometerReading Units and Calibration .
This property holds the raw magnetic flux density on the X axis.
Measured as teslas.
访问函数:
qreal | x () const |
另请参阅 QMagnetometerReading Units .
This property holds the raw magnetic flux density on the Y axis.
Measured as teslas.
访问函数:
qreal | y () const |
另请参阅 QMagnetometerReading Units .
This property holds the raw magnetic flux density on the Z axis.
Measured as teslas.
访问函数:
qreal | z () const |
另请参阅 QMagnetometerReading Units .
Default constructs an instance of QMagnetometerReading.
[虚拟]
QMagnetometerReading::
~QMagnetometerReading
()
Destroys the instance of QMagnetometerReading. The destructor is virtual.
[override virtual]
void
QMagnetometerReading::
copyValuesFrom
(
QSensorReading
*
other
)
Sets the accuracy of the reading to calibrationLevel .
另请参阅 calibrationLevel ().
Sets the raw magnetic flux density on the X axis to x .
另请参阅 x ().
Sets the raw magnetic flux density on the Y axis to y .
另请参阅 y ().
Sets the raw magnetic flux density on the Z axis to z .
另请参阅 z ().