PySide6.QtSensors.QSensorBackend

class QSensorBackend

The QSensorBackend class is a sensor implementation. More

Inheritance diagram of PySide6.QtSensors.QSensorBackend

Synopsis

Methods

Virtual methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

Sensors on a device will be represented by sub-classes of QSensorBackend .

__init__(sensor[, parent=None])
Parameters:
addDataRate(min, max)
Parameters:
  • min – float

  • max – float

Add a data rate (consisting of min and max values) for the sensor.

Note that this function should be called from the constructor so that the information is available immediately.

addOutputRange(min, max, accuracy)
Parameters:
  • min – float

  • max – float

  • accuracy – float

Add an output range (consisting of min, max values and accuracy) for the sensor.

Note that this function should be called from the constructor so that the information is available immediately.

isFeatureSupported(feature)
Parameters:

featureFeature

Return type:

bool

Checks whether a feature is supported by this sensor backend.

This is the backend side of isFeatureSupported() . Reimplement this function if the backend supports one of the additional sensor features of Feature .

Returns whether the feature feature is supported by this backend. The default implementation returns false.

newReadingAvailable()

Notify the QSensor class that a new reading is available.

reading()
Return type:

QSensorReading

If the backend has lost its reference to the reading it can call this method to get the address.

Note that you will need to down-cast to the appropriate type.

See also

setReading()

sensor()
Return type:

QSensor

Returns the sensor front end associated with this backend.

sensorBusy([busy=true])
Parameters:

busy – bool

Inform the front end of the sensor’s busy state according to the provided busy parameter.

If the sensor is set busy this implicitly calls sensorStopped() . Busy indication is typically done in start() .

Note that the front end must call isBusy() to see if the sensor is busy. If the sensor has stopped due to an error the sensorError() function should be called to notify the class of the error condition.

sensorError(error)
Parameters:

error – int

Inform the front end that a sensor error occurred. Note that this only reports an error code. It does not stop the sensor.

See also

sensorStopped()

sensorStopped()

Inform the front end that the sensor has stopped. This can be due to start() failing or for some unexpected reason (eg. hardware failure).

Note that the front end must call isActive() to see if the sensor has stopped. If the sensor has stopped due to an error the sensorError() function should be called to notify the class of the error condition.

setDataRates(otherSensor)
Parameters:

otherSensorQSensor

Set the data rates for the sensor based on otherSensor.

This is designed for sensors that are based on other sensors.

setDataRates(otherSensor);

Note that this function must be called from the constructor.

setDescription(description)
Parameters:

description – str

Set the description for the sensor.

Note that this function should be called from the constructor so that the information is available immediately.

abstract start()

Start reporting values.

abstract stop()

Stop reporting values.