Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QSensorBackend Class Reference

The QSensorBackend class is a sensor implementation. More...

 #include <QSensorBackend>

Inherits QObject.

Public Functions

void addDataRate ( qreal min, qreal max )
void addOutputRange ( qreal min, qreal max, qreal accuracy )
void newReadingAvailable ()
QSensorReading * reading () const
QSensor * sensor () const
void sensorBusy ()
void sensorError ( int error )
void sensorStopped ()
void setDataRates ( const QSensor * otherSensor )
void setDescription ( const QString & description )
T * setReading ( T * reading )
virtual void start () = 0
virtual void stop () = 0
  • 29 public functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QSensorBackend class is a sensor implementation.

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

Member Function Documentation

void QSensorBackend::addDataRate ( qreal min, qreal max )

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.

See also QSensor::availableDataRates.

void QSensorBackend::addOutputRange ( qreal min, qreal max, qreal accuracy )

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.

See also QSensor::outputRange and QSensor::outputRanges.

void QSensorBackend::newReadingAvailable ()

Notify the QSensor class that a new reading is available.

QSensorReading * QSensorBackend::reading () const

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().

QSensor * QSensorBackend::sensor () const

Returns the sensor front end associated with this backend.

void QSensorBackend::sensorBusy ()

Inform the front end that the sensor is busy. This implicitly calls sensorStopped() and is typically called from start().

Note that the front end must call QSensor::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.

void QSensorBackend::sensorError ( int error )

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().

void QSensorBackend::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 QSensor::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.

void QSensorBackend::setDataRates ( const QSensor * otherSensor )

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 should be called from the constructor so that the information is available immediately.

See also QSensor::availableDataRates and addDataRate().

void QSensorBackend::setDescription ( const QString & description )

Set the description for the sensor.

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

T * QSensorBackend::setReading ( T * reading )

This function is called to initialize the reading classes used for a sensor.

If your backend has already allocated a reading you should pass the address of this to the function. Otherwise you should pass 0 and the function will return the address of the reading your backend should use when it wants to notify the sensor API of new readings.

Note that this is a template function so it should be called with the appropriate type.

 class MyBackend : public QSensorBackend
 {
     QAccelerometerReading m_reading;
 public:
     MyBackend(QSensor *sensor)
         : QSensorBackend(sensor)
     {
         setReading<QAccelerometerReading>(&m_reading);
     }

     ...

Note that this function must be called or you will not be able to send readings to the front end.

If you do not wish to store the address of the reading you may use the reading() method to get it again later.

 class MyBackend : public QSensorBackend
 {
 public:
     MyBackend(QSensor *sensor)
         : QSensorBackend(sensor)
     {
         setReading<QAccelerometerReading>(0);
     }

     void poll()
     {
         qtimestamp timestamp;
         qreal x, y, z;
         ...
         QAccelerometerReading *reading = static_cast<QAccelerometerReading*>(reading());
         reading->setTimestamp(timestamp);
         reading->setX(x);
         reading->setY(y);
         reading->setZ(z);
     }

     ...

See also reading().

void QSensorBackend::start () [pure virtual]

Start reporting values.

void QSensorBackend::stop () [pure virtual]

Stop reporting values.

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();
Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 85
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Quarterly au hasard

Logo

Qt Quick sort de la quiétude

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtmobility-1.1
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web