Sophie

Sophie

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

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" />
<!-- qquickdrag.cpp -->
  <title>Drag QML Type | 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 ><a href="qtquick-qmlmodule.html">QML Types</a></td><td >Drag QML Type</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="#attached-properties">Attached Properties</a></li>
<li class="level1"><a href="#attached-signals">Attached Signals</a></li>
<li class="level1"><a href="#attached-methods">Attached Methods</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Drag QML Type</h1>
<span class="subtitle"></span>
<!-- $$$Drag-brief -->
<p>For specifying drag and drop events for moved Items. <a href="#details">More...</a></p>
<!-- @@@Drag -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr></table></div><ul>
<li><a href="qml-qtquick-drag-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="attached-properties"></a>
<h2 id="attached-properties">Attached Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#active-attached-prop">active</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#dragType-attached-prop">dragType</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#hotSpot-attached-prop">hotSpot</a></b></b> : QPointF</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#imageSource-attached-prop">imageSource</a></b></b> : QUrl</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#keys-attached-prop">keys</a></b></b> : stringlist</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#mimeData-attached-prop">mimeData</a></b></b> : stringlist</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#proposedAction-attached-prop">proposedAction</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#source-attached-prop">source</a></b></b> : Object</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#supportedActions-attached-prop">supportedActions</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#target-attached-prop">target</a></b></b> : Object</li>
</ul>
<a name="attached-signals"></a>
<h2 id="attached-signals">Attached Signals</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#dragFinished-signal">dragFinished</a></b></b>(DropAction <i>dropAction</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-drag.html#dragStarted-signal">dragStarted</a></b></b>()</li>
</ul>
<a name="attached-methods"></a>
<h2 id="attached-methods">Attached Methods</h2>
<ul>
<li class="fn">void <b><b><a href="qml-qtquick-drag.html#cancel-method">cancel</a></b></b>()</li>
<li class="fn">enumeration <b><b><a href="qml-qtquick-drag.html#drop-method">drop</a></b></b>()</li>
<li class="fn">void <b><b><a href="qml-qtquick-drag.html#start-method">start</a></b></b>(flags <i>supportedActions</i>)</li>
<li class="fn">void <b><b><a href="qml-qtquick-drag.html#startDrag-method">startDrag</a></b></b>(flags <i>supportedActions</i>)</li>
</ul>
<!-- $$$Drag-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
<p>Using the Drag attached property, any Item can be made a source of drag and drop events within a scene.</p>
<p>When a drag is <a href="qml-qtquick-drag.html#active-attached-prop">active</a> on an item, any change in that item's position will generate a drag event that will be sent to any <a href="qml-qtquick-droparea.html">DropArea</a> that intersects with the new position of the item. Other items which implement drag and drop event handlers can also receive these events.</p>
<p>The following snippet shows how an item can be dragged with a <a href="qml-qtquick-mousearea.html">MouseArea</a>. However, dragging is not limited to mouse drags; anything that can move an item can generate drag events, including touch events, animations and bindings.</p>
<pre class="qml">

  import QtQuick 2.0

  Item {
      width: 200; height: 200

      DropArea {
          x: 75; y: 75
          width: 50; height: 50

          Rectangle {
              anchors.fill: parent
              color: "green"

              visible: parent.containsDrag
          }
      }

      Rectangle {
          x: 10; y: 10
          width: 20; height: 20
          color: "red"

          Drag.active: dragArea.drag.active
          Drag.hotSpot.x: 10
          Drag.hotSpot.y: 10

          MouseArea {
              id: dragArea
              anchors.fill: parent

              drag.target: parent
          }
      }
  }

</pre>
<p>A drag can be terminated either by canceling it with Drag.<a href="qml-qtquick-drag.html#cancel-method">cancel()</a> or setting Drag.active to false, or it can be terminated with a drop event by calling Drag.<a href="qml-qtquick-drag.html#drop-method">drop()</a>. If the drop event is accepted, Drag.<a href="qml-qtquick-drag.html#drop-method">drop()</a> will return the <a href="qml-qtquick-drag.html#supportedActions-attached-prop">drop action</a> chosen by the recipient of the event, otherwise it will return Qt.IgnoreAction.</p>
<p><b>See also </b><a href="qtquick-draganddrop-example.html">Qt Quick Examples - Drag and Drop</a> and <a href="qtquick-externaldraganddrop-example.html">Qt Quick Examples - externaldraganddrop</a>.</p>
<!-- @@@Drag -->
<h2>Attached Property Documentation</h2>
<!-- $$$active -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="active-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="active-attached-prop"></a><span class="name">Drag.active</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds whether a drag event sequence is currently active.</p>
<p>Binding this property to the active property of <a href="qml-qtquick-mousearea.html#drag-prop">MouseArea::drag</a> will cause <a href="qml-qtquick-drag.html#startDrag-method">startDrag</a> to be called when the user starts dragging.</p>
<p>Setting this property to true will also send a QDragEnter event to the scene with the item's current position. Setting it to false will send a QDragLeave event.</p>
<p>While a drag is active any change in an item's position will send a QDragMove event with item's new position to the scene.</p>
</div></div><!-- @@@active -->
<br/>
<!-- $$$dragType -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="dragType-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="dragType-attached-prop"></a><span class="name">Drag.dragType</span> : <span class="type">enumeration</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property indicates whether to automatically start drags, do nothing, or to use backwards compatible internal drags. The default is to use backwards compatible internal drags.</p>
<p>A drag can also be started manually using <a href="qml-qtquick-drag.html#startDrag-method">startDrag</a>.</p>
<ul>
<li>Drag.None - do not start drags automatically</li>
<li>Drag.Automatic - start drags automatically</li>
<li>Drag.Internal (default) - start backwards compatible drags automatically</li>
</ul>
<p>When using <code>Drag.Automatic</code> you should also define <a href="qml-qtquick-drag.html#mimeData-attached-prop">mimeData</a> and bind the <a href="qml-qtquick-drag.html#active-attached-prop">active</a> property to the active property of <a href="qml-qtquick-mousearea.html">MouseArea</a> : <a href="qml-qtquick-mousearea.html#drag.active-prop">MouseArea::drag.active</a></p>
<p>This property was introduced in  Qt 5.2.</p>
</div></div><!-- @@@dragType -->
<br/>
<!-- $$$hotSpot -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="hotSpot-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="hotSpot-attached-prop"></a><span class="name">Drag.hotSpot</span> : <span class="type">QPointF</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the drag position relative to the top left of the item.</p>
<p>By default this is (0, 0).</p>
<p>Changes to hotSpot trigger a new drag move with the updated position.</p>
</div></div><!-- @@@hotSpot -->
<br/>
<!-- $$$imageSource -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="imageSource-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="imageSource-attached-prop"></a><span class="name">Drag.imageSource</span> : <span class="type">QUrl</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the URL of the image which will be used to represent the data during the drag and drop operation. Changing this property after the drag operation has started will have no effect.</p>
<p>The example below uses an item's contents as a drag image:</p>
<pre class="qml">

  import QtQuick 2.8

  Item {
      width: 200; height: 200

      Rectangle {
          anchors.centerIn: parent
          width: text.implicitWidth + 20; height: text.implicitHeight + 10
          color: "green"
          radius: 5

          Drag.active: dragArea.drag.active
          Drag.dragType: Drag.Automatic
          Drag.supportedActions: Qt.CopyAction
          Drag.mimeData: {
              "text/plain": "Copied text"
          }

          Text {
              id: text
              anchors.centerIn: parent
              text: "Drag me"
          }

          MouseArea {
              id: dragArea
              anchors.fill: parent

              drag.target: parent
              onPressed: parent.grabToImage(function(result) {
                  parent.Drag.imageSource = result.url
              })
          }
      }
  }

</pre>
<p>This property was introduced in  Qt 5.8.</p>
<p><b>See also </b><a href="qml-qtquick-item.html#grabToImage-method">Item::grabToImage()</a>.</p>
</div></div><!-- @@@imageSource -->
<br/>
<!-- $$$keys -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="keys-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="keys-attached-prop"></a><span class="name">Drag.keys</span> : <span class="type">stringlist</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds a list of keys that can be used by a <a href="qml-qtquick-droparea.html">DropArea</a> to filter drag events.</p>
<p>Changing the keys while a drag is active will reset the sequence of drag events by sending a drag leave event followed by a drag enter event with the new source.</p>
</div></div><!-- @@@keys -->
<br/>
<!-- $$$mimeData -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="mimeData-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="mimeData-attached-prop"></a><span class="name">Drag.mimeData</span> : <span class="type">stringlist</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds a map of mimeData that is used during <a href="qml-qtquick-drag.html#startDrag-method">startDrag</a>.</p>
<p>This property was introduced in  Qt 5.2.</p>
</div></div><!-- @@@mimeData -->
<br/>
<!-- $$$proposedAction -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="proposedAction-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="proposedAction-attached-prop"></a><span class="name">Drag.proposedAction</span> : <span class="type">enumeration</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds an action that is recommended by the drag source as a return value from Drag.<a href="qml-qtquick-drag.html#drop-method">drop()</a>.</p>
<p>Changes to proposedAction will trigger a move event with the updated proposal.</p>
</div></div><!-- @@@proposedAction -->
<br/>
<!-- $$$source -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="source-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="source-attached-prop"></a><span class="name">Drag.source</span> : <span class="type">Object</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds an object that is identified to recipients of drag events as the source of the events. By default this is the item that the Drag property is attached to.</p>
<p>Changing the source while a drag is active will reset the sequence of drag events by sending a drag leave event followed by a drag enter event with the new source.</p>
</div></div><!-- @@@source -->
<br/>
<!-- $$$supportedActions -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="supportedActions-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="supportedActions-attached-prop"></a><span class="name">Drag.supportedActions</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds return values of Drag.<a href="qml-qtquick-drag.html#drop-method">drop()</a> supported by the drag source.</p>
<p>Changing the supportedActions while a drag is active will reset the sequence of drag events by sending a drag leave event followed by a drag enter event with the new source.</p>
</div></div><!-- @@@supportedActions -->
<br/>
<!-- $$$target -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="target-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="target-attached-prop"></a><span class="name">Drag.target</span> : <span class="type">Object</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>While a drag is active this property holds the last object to accept an enter event from the dragged item, if the current drag position doesn't intersect any accepting targets it is null.</p>
<p>When a drag is not active this property holds the object that accepted the drop event that ended the drag, if no object accepted the drop or the drag was canceled the target will then be null.</p>
</div></div><!-- @@@target -->
<br/>
<h2>Attached Signal Documentation</h2>
<!-- $$$dragFinished -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="dragFinished-signal">
<td class="tblQmlFuncNode"><p>
<a name="dragFinished-signal"></a><span class="name">dragFinished</span>(<span class="type">DropAction</span> <i>dropAction</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when a drag finishes and the drag was started with the <a href="qml-qtquick-drag.html#startDrag-method">startDrag()</a> method or started automatically using the <a href="qml-qtquick-drag.html#dragType-attached-prop">dragType</a> property.</p>
<p>The corresponding handler is <code>onDragFinished</code>.</p>
</div></div><!-- @@@dragFinished -->
<br/>
<!-- $$$dragStarted -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="dragStarted-signal">
<td class="tblQmlFuncNode"><p>
<a name="dragStarted-signal"></a><span class="name">dragStarted</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when a drag is started with the <a href="qml-qtquick-drag.html#startDrag-method">startDrag()</a> method or when it is started automatically using the <a href="qml-qtquick-drag.html#dragType-attached-prop">dragType</a> property.</p>
<p>The corresponding handler is <code>onDragStarted</code>.</p>
</div></div><!-- @@@dragStarted -->
<br/>
<h2>Attached Method Documentation</h2>
<!-- $$$cancel -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="cancel-method">
<td class="tblQmlFuncNode"><p>
<a name="cancel-method"></a><span class="type">void</span> <span class="name">cancel</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Ends a drag sequence.</p>
</div></div><!-- @@@cancel -->
<br/>
<!-- $$$drop -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="drop-method">
<td class="tblQmlFuncNode"><p>
<a name="drop-method"></a><span class="type">enumeration</span> <span class="name">drop</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Ends a drag sequence by sending a drop event to the target item.</p>
<p>Returns the action accepted by the target item. If the target item or a parent doesn't accept the drop event then Qt.IgnoreAction will be returned.</p>
<p>The returned drop action may be one of:</p>
<ul>
<li>Qt.CopyAction Copy the data to the target</li>
<li>Qt.MoveAction Move the data from the source to the target</li>
<li>Qt.LinkAction Create a link from the source to the target.</li>
<li>Qt.IgnoreAction Ignore the action (do nothing with the data).</li>
</ul>
</div></div><!-- @@@drop -->
<br/>
<!-- $$$start -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="start-method">
<td class="tblQmlFuncNode"><p>
<a name="start-method"></a><span class="type">void</span> <span class="name">start</span>(<span class="type">flags</span> <i>supportedActions</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Starts sending drag events. Used for starting old-style internal drags. <a href="qml-qtquick-drag.html#startDrag-method">startDrag</a> is the new-style, preferred method of starting drags.</p>
<p>The optional <i>supportedActions</i> argument can be used to override the <a href="qml-qtquick-drag.html#supportedActions-attached-prop">supportedActions</a> property for the started sequence.</p>
</div></div><!-- @@@start -->
<br/>
<!-- $$$startDrag -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="startDrag-method">
<td class="tblQmlFuncNode"><p>
<a name="startDrag-method"></a><span class="type">void</span> <span class="name">startDrag</span>(<span class="type">flags</span> <i>supportedActions</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Starts sending drag events.</p>
<p>The optional <i>supportedActions</i> argument can be used to override the <a href="qml-qtquick-drag.html#supportedActions-attached-prop">supportedActions</a> property for the started sequence.</p>
</div></div><!-- @@@startDrag -->
<br/>
        </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>