The Qt Sensors module provides access to sensor hardware via QML and C++ interfaces.
The API is supported on Android , iOS ,和 Windows (MSVC) .
Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies.
To create your own sensor you can use the following steps:
class MyReadingPrivate; class MyReading : public QSensorReading { Q_OBJECT Q_PROPERTY(qreal myprop READ myprop) DECLARE_READING(MyReading) public: qreal myprop() const; void setMyprop(qreal myprop); }; class MySensor : public QSensor { Q_OBJECT public: explicit MySensor(QObject *parent = 0); MyReading *reading() const; static char const * const sensorType; };
As an another option the sensors are put into a Creating a sensor plugin that you can use on demand.