Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-updates > by-pkgid > 6e2327ca1c896c6d674ae53117299f21 > files > 1763

qtdeclarative5-doc-5.12.6-1.mga7.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" />
<!-- touchinteraction.qdoc -->
  <title>Qt Quick Examples - Touch Interaction | Qt Quick 5.12.6</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.12</td><td ><a href="qtquick-index.html">Qt Quick</a></td><td >Qt Quick Examples - Touch Interaction</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.6 Reference Documentation</a></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="#running-the-example">Running the Example</a></li>
<li class="level1"><a href="#multipoint-flames-example">Multipoint Flames Example</a></li>
<li class="level1"><a href="#bear-whack-example">Bear-Whack Example</a></li>
<li class="level1"><a href="#flick-resize-example">Flick Resize Example</a></li>
<li class="level1"><a href="#flickable-example">Flickable Example</a></li>
<li class="level1"><a href="#corkboards-example">Corkboards Example</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Quick Examples - Touch Interaction</h1>
<span class="subtitle"></span>
<!-- $$$touchinteraction-brief -->
<p>A collection of QML Touch Interaction examples.</p>
<!-- @@@touchinteraction -->
<!-- $$$touchinteraction-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/qml-touchinteraction-example.png" alt="" /></p><p><i>Touch Interaction</i> is a collection of small QML examples relating to touch interaction methods. For more information, visit <a href="qtquick-input-topic.html">Important Concepts In Qt Quick - User Input</a>.</p>
<a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<a name="multipoint-flames-example"></a>
<h2 id="multipoint-flames-example">Multipoint Flames Example</h2>
<p><i>Multipoint Flames</i> demonstrates distinguishing different fingers in a <a href="qml-qtquick-multipointtoucharea.html">MultiPointTouchArea</a>, by assigning a different colored flame to each touch point.</p>
<p>The MultipointTouchArea sets up multiple touch points:</p>
<pre class="qml">

      MultiPointTouchArea {
          anchors.fill: parent
          minimumTouchPoints: 1
          maximumTouchPoints: 5
          touchPoints: [
              TouchPoint { id: touch1 },
              TouchPoint { id: touch2 },
              TouchPoint { id: touch11 },
              TouchPoint { id: touch21 },
              TouchPoint { id: touch31 }
          ]
      }

</pre>
<p>The flames are then simply bound to the coordinates of the touch point, and whether it is currently pressed, as follows:</p>
<pre class="qml">

      ParticleFlame {
          color: "red"
          emitterX: touch1.x
          emitterY: touch1.y
          emitting: touch1.pressed
      }

</pre>
<a name="bear-whack-example"></a>
<h2 id="bear-whack-example">Bear-Whack Example</h2>
<p><i>Bear-Whack</i> demonstrates using <a href="qml-qtquick-multipointtoucharea.html">MultiPointTouchArea</a> to add multiple finger support to a simple game. The interaction with the game is done through a <a href="qml-qtquick-particles-spritegoal.html">SpriteGoal</a> that follows the <a href="qml-qtquick-touchpoint.html">TouchPoint</a>. The TouchPoints added to the <a href="qml-qtquick-multipointtoucharea.html">MultiPointTouchArea</a> are a component with the relevant logic embedded into it:</p>
<pre class="qml">

  TouchPoint {
      id: container
      property ParticleSystem system
      onPressedChanged: {
          if (pressed) {
              timer.restart();
              child.enabled = true;
              system.explode(x,y);
          }
      }
      property QtObject obj: Timer {
          id: timer
          interval: 100
          running: false
          repeat: false
          onTriggered: child.enabled = false
      }
      property Item child: SpriteGoal {
          enabled: false
          x: container.area.x - 16
          y: container.area.y - 16
          width: container.area.width + 32
          height: container.area.height + 32 //+32 so it doesn't have to hit the exact center
          system: container.system
          parent: container.system
          goalState: "falling"
      }
  }

</pre>
<a name="flick-resize-example"></a>
<h2 id="flick-resize-example">Flick Resize Example</h2>
<p><i>Flick Resize</i> uses a <a href="qml-qtquick-pincharea.html">PinchArea</a> to implement a <i>pinch-to-resize</i> behavior. This is easily achieved by listening to the <a href="qml-qtquick-pincharea.html">PinchArea</a> signals and responding to user input.</p>
<pre class="qml">

  onPinchStarted: {
      initialWidth = flick.contentWidth
      initialHeight = flick.contentHeight
  }

  onPinchUpdated: {
      // adjust content pos due to drag
      flick.contentX += pinch.previousCenter.x - pinch.center.x
      flick.contentY += pinch.previousCenter.y - pinch.center.y

      // resize content
      flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center)
  }

  onPinchFinished: {
      // Move its content within bounds.
      flick.returnToBounds()
  }

</pre>
<a name="flickable-example"></a>
<h2 id="flickable-example">Flickable Example</h2>
<p><i>Flickable</i> is a simple example demonstrating the <a href="qml-qtquick-flickable.html">Flickable</a> type.</p>
<pre class="qml">

  Rectangle {
  width: 320
  height: 480
  Flickable {
      anchors.fill: parent
      contentWidth: 1200
      contentHeight: 1200
      Rectangle {
          width: 1000
          height: 1000

</pre>
<a name="corkboards-example"></a>
<h2 id="corkboards-example">Corkboards Example</h2>
<p><i>Corkboards</i> shows another use for <a href="qml-qtquick-flickable.html">Flickable</a>, with QML types within the flickable object that respond to mouse and keyboard interaction. This behavior does not require special code as the Qt Quick types already cooperate with the Flickable type for accepting touch events.</p>
<p>Files:</p>
<ul>
<li><a href="qtquick-touchinteraction-flickable-basic-flickable-qml.html">touchinteraction/flickable/basic-flickable.qml</a></li>
<li><a href="qtquick-touchinteraction-flickable-content-panel-qml.html">touchinteraction/flickable/content/Panel.qml</a></li>
<li><a href="qtquick-touchinteraction-flickable-corkboards-qml.html">touchinteraction/flickable/corkboards.qml</a></li>
<li><a href="qtquick-touchinteraction-main-cpp.html">touchinteraction/main.cpp</a></li>
<li><a href="qtquick-touchinteraction-multipointtouch-bearwhack-qml.html">touchinteraction/multipointtouch/bearwhack.qml</a></li>
<li><a href="qtquick-touchinteraction-multipointtouch-content-augmentedtouchpoint-qml.html">touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml</a></li>
<li><a href="qtquick-touchinteraction-multipointtouch-content-bearwhackparticlesystem-qml.html">touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml</a></li>
<li><a href="qtquick-touchinteraction-multipointtouch-content-particleflame-qml.html">touchinteraction/multipointtouch/content/ParticleFlame.qml</a></li>
<li><a href="qtquick-touchinteraction-multipointtouch-multiflame-qml.html">touchinteraction/multipointtouch/multiflame.qml</a></li>
<li><a href="qtquick-touchinteraction-pincharea-flickresize-qml.html">touchinteraction/pincharea/flickresize.qml</a></li>
<li><a href="qtquick-touchinteraction-touchinteraction-pro.html">touchinteraction/touchinteraction.pro</a></li>
<li><a href="qtquick-touchinteraction-touchinteraction-qml.html">touchinteraction/touchinteraction.qml</a></li>
<li><a href="qtquick-touchinteraction-touchinteraction-qmlproject.html">touchinteraction/touchinteraction.qmlproject</a></li>
<li><a href="qtquick-touchinteraction-touchinteraction-qrc.html">touchinteraction/touchinteraction.qrc</a></li>
</ul>
<p>Images:</p>
<ul>
<li><a href="images/used-in-examples/touchinteraction/flickable/content/cork.jpg">touchinteraction/flickable/content/cork.jpg</a></li>
<li><a href="images/used-in-examples/touchinteraction/flickable/content/note-yellow.png">touchinteraction/flickable/content/note-yellow.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/flickable/content/tack.png">touchinteraction/flickable/content/tack.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/multipointtouch/content/Bear0.png">touchinteraction/multipointtouch/content/Bear0.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/multipointtouch/content/Bear1.png">touchinteraction/multipointtouch/content/Bear1.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/multipointtouch/content/Bear2.png">touchinteraction/multipointtouch/content/Bear2.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/multipointtouch/content/Bear3.png">touchinteraction/multipointtouch/content/Bear3.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/multipointtouch/content/BearB.png">touchinteraction/multipointtouch/content/BearB.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/multipointtouch/content/blur-circle.png">touchinteraction/multipointtouch/content/blur-circle.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/multipointtouch/content/blur-circle3.png">touchinteraction/multipointtouch/content/blur-circle3.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/multipointtouch/content/heart-blur.png">touchinteraction/multipointtouch/content/heart-blur.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/multipointtouch/content/title.png">touchinteraction/multipointtouch/content/title.png</a></li>
<li><a href="images/used-in-examples/touchinteraction/pincharea/qt-logo.jpg">touchinteraction/pincharea/qt-logo.jpg</a></li>
</ul>
</div>
<!-- @@@touchinteraction -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 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>