Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-updates > by-pkgid > aa084d0e0126d94ee0fb846ebdf50e37 > files > 327

qtsensors5-doc-5.9.4-1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qmlsensorgestures.qdoc -->
  <title>Qt Sensors - SensorGesture QML Type example | Qt Sensors 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtsensors-index.html">Qt Sensors</a></td><td ><a href="qtsensors-examples.html">Qt Sensors Examples</a></td><td >Qt Sensors - SensorGesture QML Type example</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#overview">Overview</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Sensors - SensorGesture QML Type example</h1>
<span class="subtitle"></span>
<!-- $$$qmlsensorgestures-description -->
<div class="descr"> <a name="details"></a>
<a name="overview"></a>
<h2 id="overview">Overview</h2>
<p>To write a QML application that will use the gesture plugin, following steps are needed:</p>
<p>Import the <a href="qtsensors-module.html">QtSensors</a> 5.x module:</p>
<pre class="qml">

  import QtSensors 5.0

</pre>
<p>Add the <a href="qml-qtsensors-sensorgesture.html">SensorGesture</a> QML type into your qml file.</p>
<pre class="qml">

      <span class="type"><a href="qml-qtsensors-sensorgesture.html">SensorGesture</a></span> {
          <span class="name">id</span>: <span class="name">sensorGesture</span>
          <span class="name">enabled</span>: <span class="number">false</span>
          <span class="name">onDetected</span>: {
              <span class="keyword">if</span> (<span class="name">gesture</span> <span class="operator">!==</span> <span class="name">oldGesture</span>)
                  <span class="name">count</span> <span class="operator">=</span> <span class="number">0</span>;
              <span class="name">valueText</span>.<span class="name">text</span> <span class="operator">=</span> <span class="name">gesture</span> <span class="operator">+</span> <span class="string">&quot; &quot;</span> <span class="operator">+</span> <span class="name">count</span>;
              <span class="name">oldGesture</span> <span class="operator">=</span> <span class="name">gesture</span>;
              count++;
          }
          <span class="name">onEnabledChanged</span>: {
              <span class="name">valueText</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">&quot;&quot;</span>
          }
      }

</pre>
<p>Each <a href="qml-qtsensors-sensorgesture.html">SensorGesture</a> QML type contains a property called gestures. This example uses an alias <code>gestureId</code> for this property.</p>
<pre class="qml">

      property <span class="type">alias</span> <span class="name">gestureId</span>: <span class="name">sensorGesture</span>.<span class="name">gestures</span>

</pre>
<p>Then, the gesture or gestures to use can be specified using the alias:</p>
<pre class="qml">

          <span class="name">onSelectedGestureChanged</span>: {
              <span class="name">gesture</span>.<span class="name">enabled</span> <span class="operator">=</span> <span class="number">false</span>;
              <span class="name">gesture</span>.<span class="name">gestureId</span> <span class="operator">=</span> <span class="name">gestureList</span>.<span class="name">selectedGesture</span>;
              ...
          }

</pre>
<p>A list of all available gestures is accessible through the <code>availableGestures</code> property:</p>
<pre class="qml">

          <span class="type">ListView</span> {
              <span class="name">id</span>: <span class="name">gestureList</span>

              <span class="name">model</span>: <span class="name">gesture</span>.<span class="name">availableGestures</span>
              ...
          }

</pre>
<p>Files:</p>
<ul>
<li><a href="qtsensors-qmlsensorgestures-button-qml.html">qmlsensorgestures/Button.qml</a></li>
<li><a href="qtsensors-qmlsensorgestures-gesturelist-qml.html">qmlsensorgestures/GestureList.qml</a></li>
<li><a href="qtsensors-qmlsensorgestures-gestureview-qml.html">qmlsensorgestures/GestureView.qml</a></li>
<li><a href="qtsensors-qmlsensorgestures-gesturesview-qml.html">qmlsensorgestures/GesturesView.qml</a></li>
<li><a href="qtsensors-qmlsensorgestures-makefile-qml.html">qmlsensorgestures/Makefile.qml</a></li>
<li><a href="qtsensors-qmlsensorgestures-qmlsensorgestures-qml.html">qmlsensorgestures/qmlsensorgestures.qml</a></li>
<li><a href="qtsensors-qmlsensorgestures-plugin-qcountergestureplugin-cpp.html">qmlsensorgestures/plugin/qcountergestureplugin.cpp</a></li>
<li><a href="qtsensors-qmlsensorgestures-plugin-qcountergestureplugin-h.html">qmlsensorgestures/plugin/qcountergestureplugin.h</a></li>
<li><a href="qtsensors-qmlsensorgestures-plugin-qcounterrecognizer-cpp.html">qmlsensorgestures/plugin/qcounterrecognizer.cpp</a></li>
<li><a href="qtsensors-qmlsensorgestures-plugin-qcounterrecognizer-h.html">qmlsensorgestures/plugin/qcounterrecognizer.h</a></li>
<li><a href="qtsensors-qmlsensorgestures-main-cpp.html">qmlsensorgestures/main.cpp</a></li>
<li><a href="qtsensors-qmlsensorgestures-qml-pro.html">qmlsensorgestures/qml.pro</a></li>
<li><a href="qtsensors-qmlsensorgestures-qml-qrc.html">qmlsensorgestures/qml.qrc</a></li>
<li><a href="qtsensors-qmlsensorgestures-qmlsensorgestures-pro.html">qmlsensorgestures/qmlsensorgestures.pro</a></li>
<li><a href="qtsensors-qmlsensorgestures-plugin-plugin-pro.html">qmlsensorgestures/plugin/plugin.pro</a></li>
</ul>
</div>
<p><b>See also </b><a href="qtsensors-shakeit-example.html">Qt Sensors - ShakeIt QML Example</a> and <a href="sensorgesture-plugins-topics.html#qt-sensor-gestures">Qt Sensor Gestures</a>.</p>
<!-- @@@qmlsensorgestures -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed 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.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>