En esta página

QSensorManager Class

La clase QSensorManager gestiona el registro y la creación de backends de sensores. Más...

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

Miembros públicos estáticos

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

Descripción detallada

Los plugins de sensores registran backends utilizando la función registerBackend().

Cuando se llame a QSensor::connectToBackend(), se llamará a la función createBackend().

Documentación de la función miembro

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

Crear un backend para sensor. Devuelve null si no existe un backend adecuado.

[static] bool QSensorManager::isBackendRegistered(const QByteArray &type, const QByteArray &identifier)

Devuelve true si el backend identificado por type y identifier está registrado.

Este es un método práctico que ayuda a los plugins que realizan un registro dinámico.

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

Registre un sensor para type. El identifier debe ser único.

Se pedirá a factory que cree instancias del backend.

Los identificadores de sensor que empiecen por generic o dummy tienen menos prioridad a la hora de elegir el sensor predeterminado si se encuentran otros sensores.

[static] void QSensorManager::setDefaultBackend(const QByteArray &type, const QByteArray &identifier)

Establece o sobrescribe el sensor type con el backend identifier.

[static] void QSensorManager::unregisterBackend(const QByteArray &type, const QByteArray &identifier)

Desregistre el backend para type con identifier.

Tenga en cuenta que esto sólo impide que se creen nuevas instancias del backend. No invalida las instancias existentes del backend. El código del backend debe manejar por sí mismo la desaparición del hardware subyacente.

© 2026 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.