QSensorManagerclass handles registration and creation of sensor backends. 更多 …
def
createBackend
(sensor)
def
isBackendRegistered
(type, identifier)
def
registerBackend
(type, identifier, factory)
def
setDefaultBackend
(type, identifier)
def
unregisterBackend
(type, identifier)
Sensor plugins register backends using the
registerBackend()函数。当
connectToBackend()is called, thecreateBackend()function will be called.
QSensorManager
¶
PySide2.QtSensors.QSensorManager.
createBackend
(
sensor
)
¶
sensor
–
QSensor
Create a backend for
sensor
. Returns null if no suitable backend exists.
PySide2.QtSensors.QSensorManager.
isBackendRegistered
(
type
,
identifier
)
¶
type
–
QByteArray
identifier
–
QByteArray
bool
Returns true if the backend identified by
type
and
identifier
is registered.
This is a convenience method that helps out plugins doing dynamic registration.
PySide2.QtSensors.QSensorManager.
registerBackend
(
type
,
identifier
,
factory
)
¶
type
–
QByteArray
identifier
–
QByteArray
factory
–
QSensorBackendFactory
Register a sensor for
type
。
identifier
must be unique.
factory
will be asked to create instances of the backend.
PySide2.QtSensors.QSensorManager.
setDefaultBackend
(
type
,
identifier
)
¶
type
–
QByteArray
identifier
–
QByteArray
Sets or overwrite the sensor
type
with the backend
identifier
.
PySide2.QtSensors.QSensorManager.
unregisterBackend
(
type
,
identifier
)
¶
type
–
QByteArray
identifier
–
QByteArray
Unregister the backend for
type
with
identifier
.
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.