Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 50facae208d4a6f280e44a513b104320 > files > 1437

qt-mobility-doc-1.2.0-13.mga5.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qml-sensors.qdoc -->
  <title>Qt Mobility 1.2: Sensors QML Plugin</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>QtMobility Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li>Sensors QML Plugin</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#overview">Overview</a></li>
<li class="level1"><a href="#qml-elements">QML Elements</a></li>
</ul>
</div>
<h1 class="title">Sensors QML Plugin</h1>
<span class="subtitle"></span>
<!-- $$$qml-sensors.html-description -->
<div class="descr"> <a name="details"></a>
<a name="overview"></a>
<h2>Overview</h2>
<p>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.</p>
<p>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.</p>
<p>The QML code that reads the value is quite simple. Here we see a QML component <i>orientation</i> declared which is an <a href="qml-orientationsensor.html">OrientationSensor</a> element. First the sensor is started by setting the <a href="qml-sensor.html#active-prop">active</a> property to <i>true</i>. The element receives a signal when the reading changes and it is picked up by the <i>onReadingChanged</i> slot. Now the <a href="qml-orientationsensor.html#reading-prop">reading</a> 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 <a href="qml-orientationreading.html">OrientationReading</a> element.</p>
<pre class="qml"> <span class="type"><a href="qml-orientationsensor.html">OrientationSensor</a></span> {
     <span class="name">id</span>: <span class="name">orientation</span>
     <span class="name">active</span>: <span class="number">true</span>

     <span class="name">onReadingChanged</span>: {

         <span class="keyword">if</span> (<span class="name">reading</span>.<span class="name">orientation</span> <span class="operator">==</span> <span class="name">OrientationReading</span>.<span class="name">FaceUp</span>)
             <span class="name">content</span>.<span class="name">state</span> <span class="operator">=</span> <span class="string">&quot;FaceUp&quot;</span>;

         <span class="comment">// ... more tests for different orientations ...</span>
     }
 }</pre>
<p>Other sensors can be treated in a similar manner. For example, the <a href="qml-compass.html">Compass</a> sensor could have almost identical coding</p>
<pre class="qml"> <span class="type"><a href="qml-compass.html">Compass</a></span> {
     <span class="name">id</span>: <span class="name">compass</span>
     <span class="name">active</span>: <span class="number">true</span>

     <span class="name">onReadingChanged</span>: {
         <span class="name">compassHeading</span>.<span class="name">text</span> <span class="operator">=</span> <span class="name">reading</span>.<span class="name">azimuth</span>;

         <span class="comment">// ...</span>
     }
 }</pre>
<a name="qml-elements"></a>
<h2>QML Elements</h2>
<table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-accelerometer.html">QML Accelerometer Element</a></p></td><td class="tblDescr"><p>The Accelerometer element reports on linear acceleration along the X, Y and Z axes.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-ambientlightsensor.html">QML AmbientLightSensor Element</a></p></td><td class="tblDescr"><p>The AmbientLightSensor element repors on ambient lighting conditions.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-compass.html">QML Compass Element</a></p></td><td class="tblDescr"><p>The Compass element reports on heading using magnetic north as a reference.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-gyroscope.html">QML Gyroscope Element</a></p></td><td class="tblDescr"><p>The Gyroscope element reports on rotational acceleration around the X, Y and Z axes.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-lightsensor.html">QML LightSensor Element</a></p></td><td class="tblDescr"><p>The LightSensor element reports on light levels using LUX.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-magnetometer.html">QML Magnetometer Element</a></p></td><td class="tblDescr"><p>The Magnetometer element reports on magnetic field strength along the Z, Y and Z axes.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-orientationsensor.html">QML OrientationSensor Element</a></p></td><td class="tblDescr"><p>The OrientationSensor element reports device orientation.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-proximitysensor.html">QML ProximitySensor Element</a></p></td><td class="tblDescr"><p>The ProximitySensor element reports on object proximity.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-rotationsensor.html">QML RotationSensor Element</a></p></td><td class="tblDescr"><p>The RotationSensor element reports on device rotation around the X, Y and Z axes.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-sensor.html">QML Sensor Element</a></p></td><td class="tblDescr"><p>The Sensor element serves as a base type for sensors.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-tapsensor.html">QML TapSensor Element</a></p></td><td class="tblDescr"><p>The TapSensor element reports tap and double tap events along the X, Y and Z axes.</p></td></tr>
</table>
<table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-accelerometerreading.html">QML AccelerometerReading Element</a></p></td><td class="tblDescr"><p>The AccelerometerReading element holds the most recent Accelerometer reading.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-ambientlightreading.html">QML AmbientLightReading Element</a></p></td><td class="tblDescr"><p>The AmbientLightReading element holds the most AmbientLightSensor reading.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-compassreading.html">QML CompassReading Element</a></p></td><td class="tblDescr"><p>The CompassReading element holds the most recent Compass reading.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-gyroscopereading.html">QML GyroscopeReading Element</a></p></td><td class="tblDescr"><p>The GyroscopeReading element holds the most recent Gyroscope reading.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-lightreading.html">QML LightReading Element</a></p></td><td class="tblDescr"><p>The LightReading element holds the most recent LightSensor reading.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-magnetometerreading.html">QML MagnetometerReading Element</a></p></td><td class="tblDescr"><p>The MagnetometerReading element holds the most recent Magnetometer reading.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-orientationreading.html">QML OrientationReading Element</a></p></td><td class="tblDescr"><p>The OrientationReading element holds the most recent OrientationSensor reading.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-proximityreading.html">QML ProximityReading Element</a></p></td><td class="tblDescr"><p>The ProximityReading element holds the most recent ProximitySensor reading.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-rotationreading.html">QML RotationReading Element</a></p></td><td class="tblDescr"><p>The RotationReading element holds the most recent RotationSensor reading.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-sensorreading.html">QML SensorReading Element</a></p></td><td class="tblDescr"><p>The SensorReading element serves as a base type for sensor readings.</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-tapreading.html">QML TapReading Element</a></p></td><td class="tblDescr"><p>The TapReading element holds the most recent TapSensor reading.</p></td></tr>
</table>
</div>
<!-- @@@qml-sensors.html -->
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
  <p>
     <acronym title="Copyright">&copy;</acronym> 2008-2011 Nokia Corporation and/or its
     subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
     in Finland and/or other countries worldwide.</p>
  <p>
     All other trademarks are property of their respective owners. <a title="Privacy Policy"
     href="http://qt.nokia.com/about/privacy-policy">Privacy Policy</a></p>
  <br />
  <p>
    Licensees holding valid Qt Commercial licenses may use this document in accordance with the    Qt Commercial License Agreement provided with the Software or, alternatively, in accordance    with the terms contained in a written agreement between you and Nokia.</p>
  <p>
    Alternatively, this document may be used under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU
    Free Documentation License version 1.3</a>
    as published by the Free Software Foundation.</p>
</div>
</body>
</html>