QSensorManager Class

The QSensorManager class handles registration and creation of sensor backends. 更多...

头: #include <QSensorManager>
CMake: find_package(Qt6 REQUIRED COMPONENTS Sensors)
target_link_libraries(mytarget PRIVATE Qt6::Sensors)
qmake: QT += sensors

静态公共成员

QSensorBackend * createBackend (QSensor * sensor )
bool isBackendRegistered (const QByteArray & type , const QByteArray & 标识符 )
void registerBackend (const QByteArray & type , const QByteArray & 标识符 , QSensorBackendFactory * factory )
void setDefaultBackend (const QByteArray & type , const QByteArray & 标识符 )
void unregisterBackend (const QByteArray & type , const QByteArray & 标识符 )

详细描述

Sensor plugins register backends using the registerBackend () 函数。

QSensor::connectToBackend () is called, the createBackend () function will be called.

成员函数文档编制

[static] QSensorBackend *QSensorManager:: createBackend ( QSensor * sensor )

Create a backend for sensor . Returns null if no suitable backend exists.

[static] bool QSensorManager:: isBackendRegistered (const QByteArray & type , const QByteArray & 标识符 )

Returns true if the backend identified by type and 标识符 is registered.

This is a convenience method that helps out plugins doing dynamic registration.

[static] void QSensorManager:: registerBackend (const QByteArray & type , const QByteArray & 标识符 , QSensorBackendFactory * factory )

Register a sensor for type 标识符 必须唯一。

The factory will be asked to create instances of the backend.

Sensor identifiers starting with generic or dummy are given lower priority when choosing the default sensor if other sensors are found.

[static] void QSensorManager:: setDefaultBackend (const QByteArray & type , const QByteArray & 标识符 )

Sets or overwrite the sensor type with the backend 标识符 .

[static] void QSensorManager:: unregisterBackend (const QByteArray & type , const QByteArray & 标识符 )

Unregister the backend for type with 标识符 .

Note that this only prevents new instance of the backend from being created. It does not invalidate the existing instances of the backend. The backend code should handle the disappearance of the underlying hardware itself.