Home · All Classes · All Functions ·

Sensors API (technology preview)

Warning: This API should be considered in a technology preview state. It is under development and subject to change.

The Sensors API provides access to hardware sensors.

This covers both high-level sensors such as screen orientation (portrait, landscape) and low-level, real-time sensors such as accelerometer data.

Overview

There are 2 ways to use a sensor. If you just want the default sensor for a particular type, instantiate that class.

    // On the heap (deleted when this object is deleted)
    QAccelerationSensor *sensor = new QAccelerationSensor(this);

    // On the stack (eg. to check the orientation on startup)
    QOrientationSensor orient_sensor;

The QSensorFactory class can also create a sensor for you as well as listing the available sensors on the device.

The API supports sensors that poll for their data and sensors that push data to the app as it arrives. Each sensor will support certain update policies that determine how your application can receive the data from the sensor.

Client API

The client API is designed around sub-classes of QSensor. These classes are instantiated in the client application and connect to a QSensorBackend instance that either talks directly to hardware or via a system API. Typically the application will use sub-classes of QSensor from the QtSensors API but third party sub-classes may be used as well.

Backend API

QSensor instances talk to a backend object. Backends are usually supplied with the QtSensors library for a specific device although third party backends may be used as well. A backend may talk directly to hardware or it may talk to a system service. In some instances it may even talk to another backend or to another device. An example of this is the rotation sensor backend for devices that lack a rotation sensor but have a linear acceleration sensor. This backend talks directly to an acceleration sensor backend.

Main Classes

If you want to use the sensors on a device, these are the classes to use.

QAccelerometerReadingReports on linear acceleration along the X, Y and Z axes
QAmbientLightReadingRepresents one reading from the ambient light sensor
QCompassReadingRepresents one reading from a compass
QMagnetometerReadingRepresents one reading from the magnetometer
QOrientationReadingRepresents one reading from the orientation sensor
QProximityReadingRepresents one reading from the proximity sensor
QRotationReadingRepresents one reading from the rotation sensor
QSensorRepresents a single hardware sensor
QSensorFactoryReturns the sensors on a device
QSensorFilterEfficient callback facility for asynchronous notifications of sensor changes
QSensorReadingHolds the readings from the sensor
QTapReadingRepresents one reading from the tap sensor

Helper Classes

These classes provide convenience wrappers that reduce the need for casting.

QAccelerometerConvenience wrapper around QSensor
QAccelerometerFilterConvenience wrapper around QSensorFilter
QAmbientLightFilterConvenience wrapper around QSensorFilter
QAmbientLightSensorConvenience wrapper around QSensor
QCompassConvenience wrapper around QSensor
QCompassFilterConvenience wrapper around QSensorFilter
QMagnetometerConvenience wrapper around QSensor
QMagnetometerFilterConvenience wrapper around QSensorFilter
QOrientationFilterConvenience wrapper around QSensorFilter
QOrientationSensorConvenience wrapper around QSensor
QProximityFilterConvenience wrapper around QSensorFilter
QProximitySensorConvenience wrapper around QSensor
QRotationFilterConvenience wrapper around QSensorFilter
QRotationSensorConvenience wrapper around QSensor
QTapFilterConvenience wrapper around QSensorFilter
QTapSensorConvenience wrapper around QSensor

Backend Classes

If you are making sensors available through the Sensors API, these are the classes to use.

QSensorBackendSensor implementation
QSensorBackendFactoryInstantiates instances of QSensorBackend
QSensorManagerReturns the sensors on a device
QSensorPluginInterfaceThe pure virtual interface to sensor plugins


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Mobility Project 1.0.0