Changes to Qt Sensors

Qt 6 是努力使框架更高效,且更易于使用的结果。

为兼容每个发行的所有公共 API,我们试着维护二进制和源代码。但是,为使 Qt 成为更优框架,一些改变是不可避免的。

In this topic we summarize those changes in Qt Sensors, and provide guidance to handle them.

Sensor Gesture support

The Gesture support has been removed. In its current shape the gestures needs rethinking to be of more use for the developers. To track this please see QTBUG-95649 .

平台注意事项

Windows

On Windows, sensors are supported in Qt installations that were built with MSVC.

sensorfw

sensorfw does not yet have a Qt 6 port and is therefore not yet supported by sensors in Qt 6.

TI Sensor Tag

Support for TI Sensor Tag has been removed.

Removed sensors

QAltimeter, QDistanceSensor, QHolsterSensor and their QML counterparts did no longer have a backend implementation and have been removed.

QIRProximitySensor, QLidSensor, and QTapSensor have only sensorfw backend, and as such they are not currently listed as supported sensor types.

Linux

The Linux sysfs accelerometer support has been removed. The backend is undocumented and has been without any real activity for almost 10 years.

API 变化

Deleted typedef for qtimestamp

The typedef for the historical, QtMobility-era, qtimestamp has been removed. Use the actual type quint64 直接。

Renamed sensor type string to sensorType

The subclasses of QSensor implement a char const* string which defines the string that identifies the base sensor. This static type field shadowed the baseclass QSensor::type () method, leading to unnecessary compilation errors and consequent workarounds. The type string has been now renamed as sensorType .

Renamed LidReading::backLidChanged property to backLidClosed

The property name is now aligned with the frontLidClosed property of the same QML type.

Added parameter to QSensorBackend::sensorBusy() to be able to also clear

the busy state

QSensor::busy property and its accessor, QSensor::isBusy() , can be used to check if the sensor is busy or not. To allow this property to better reflect the sensor backend's state, QSensorBackend::sensorBusy () now accepts a boolean parameter. This busy parameter is used to set/unset the backend busy state and notify the QSensor interface attached to it.

The default value for the QSensorBackend::sensorBusy () parameter is true which results in the original behavior (except the added signal emission). This means that in most if not all cases the changes are not mandatory. Instead it is up to the individual sensor backend implementations to decide if the changes are useful.

Sensor::type and and QSensor::type properties marked as constant

type property cannot change after instantiation and is marked as constant in both C++ and QML.