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  · 

Sensors QML Plugin

Overview

The QML Sensors Plugin provides an easy to use interface to the Sensors API. It enables us to receive sensor events and to read current values from sensors.

The plugin contains many sensor types and access functions to read values from them. As an example consider the orientation sensor. The orientation example simply displays text on-screen to show the current orientation.

The QML code that reads the value is quite simple. Here we see a QML component orientation declared which is an OrientationSensor element. First the sensor is started by setting the active property to true. The element receives a signal when the reading changes and it is picked up by the onReadingChanged slot. Now the reading property of this element can be used to extract the current orientation so that it can be compared against the defined values of various orientations in the OrientationReading element.

 OrientationSensor {
     id: orientation
     active: true

     onReadingChanged: {

         if (reading.orientation == OrientationReading.FaceUp)
             content.state = "FaceUp";

         // ... more tests for different orientations ...
     }
 }

Other sensors can be treated in a similar manner. For example, the Compass sensor could have almost identical coding

 Compass {
     id: compass
     active: true

     onReadingChanged: {
         compassHeading.text = reading.azimuth;

         // ...
     }
 }

QML Elements

QML Accelerometer Element

The Accelerometer element reports on linear acceleration along the X, Y and Z axes.

QML AmbientLightSensor Element

The AmbientLightSensor element repors on ambient lighting conditions.

QML Compass Element

The Compass element reports on heading using magnetic north as a reference.

QML Gyroscope Element

The Gyroscope element reports on rotational acceleration around the X, Y and Z axes.

QML LightSensor Element

The LightSensor element reports on light levels using LUX.

QML Magnetometer Element

The Magnetometer element reports on magnetic field strength along the Z, Y and Z axes.

QML OrientationSensor Element

The OrientationSensor element reports device orientation.

QML ProximitySensor Element

The ProximitySensor element reports on object proximity.

QML RotationSensor Element

The RotationSensor element reports on device rotation around the X, Y and Z axes.

QML Sensor Element

The Sensor element serves as a base type for sensors.

QML TapSensor Element

The TapSensor element reports tap and double tap events along the X, Y and Z axes.

QML AccelerometerReading Element

The AccelerometerReading element holds the most recent Accelerometer reading.

QML AmbientLightReading Element

The AmbientLightReading element holds the most AmbientLightSensor reading.

QML CompassReading Element

The CompassReading element holds the most recent Compass reading.

QML GyroscopeReading Element

The GyroscopeReading element holds the most recent Gyroscope reading.

QML LightReading Element

The LightReading element holds the most recent LightSensor reading.

QML MagnetometerReading Element

The MagnetometerReading element holds the most recent Magnetometer reading.

QML OrientationReading Element

The OrientationReading element holds the most recent OrientationSensor reading.

QML ProximityReading Element

The ProximityReading element holds the most recent ProximitySensor reading.

QML RotationReading Element

The RotationReading element holds the most recent RotationSensor reading.

QML SensorReading Element

The SensorReading element serves as a base type for sensor readings.

QML TapReading Element

The TapReading element holds the most recent TapSensor reading.

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 59
  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. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Labs au hasard

Logo

Construire l'avenir : (ré-)introduction aux composants de Qt Quick

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. 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.2
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