Sophie

Sophie

distrib > CentOS > 5 > i386 > by-pkgid > d5f6a048a2b223e97fccd86095a60071 > files > 4024

qt4-doc-4.2.1-1.el5_7.1.i386.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/src/gui/kernel/qdrag.cpp -->
<head>
  <title>Qt 4.2: QDrag Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QDrag Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1>
<p>The QDrag class provides support for MIME-based drag and drop data transfer. <a href="#details">More...</a></p>
<pre> #include &lt;QDrag&gt;</pre><p>Inherits <a href="qobject.html">QObject</a>.</p>
<ul>
<li><a href="qdrag-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qdrag.html#QDrag">QDrag</a></b> ( QWidget * <i>dragSource</i> )</li>
<li><div class="fn"/><b><a href="qdrag.html#dtor.QDrag">~QDrag</a></b> ()</li>
<li><div class="fn"/>QPoint <b><a href="qdrag.html#hotSpot">hotSpot</a></b> () const</li>
<li><div class="fn"/>QMimeData * <b><a href="qdrag.html#mimeData">mimeData</a></b> () const</li>
<li><div class="fn"/>QPixmap <b><a href="qdrag.html#pixmap">pixmap</a></b> () const</li>
<li><div class="fn"/>void <b><a href="qdrag.html#setDragCursor">setDragCursor</a></b> ( const QPixmap &amp; <i>cursor</i>, Qt::DropAction <i>action</i> )</li>
<li><div class="fn"/>void <b><a href="qdrag.html#setHotSpot">setHotSpot</a></b> ( const QPoint &amp; <i>hotspot</i> )</li>
<li><div class="fn"/>void <b><a href="qdrag.html#setMimeData">setMimeData</a></b> ( QMimeData * <i>data</i> )</li>
<li><div class="fn"/>void <b><a href="qdrag.html#setPixmap">setPixmap</a></b> ( const QPixmap &amp; <i>pixmap</i> )</li>
<li><div class="fn"/>QWidget * <b><a href="qdrag.html#source">source</a></b> () const</li>
<li><div class="fn"/>Qt::DropAction <b><a href="qdrag.html#start">start</a></b> ( Qt::DropActions <i>request</i> = Qt::CopyAction )</li>
<li><div class="fn"/>QWidget * <b><a href="qdrag.html#target">target</a></b> () const</li>
</ul>
<ul>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"/>void <b><a href="qdrag.html#actionChanged">actionChanged</a></b> ( Qt::DropAction <i>action</i> )</li>
<li><div class="fn"/>void <b><a href="qdrag.html#targetChanged">targetChanged</a></b> ( QWidget * <i>newTarget</i> )</li>
</ul>
<ul>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QDrag class provides support for MIME-based drag and drop data transfer.</p>
<p>Drag and drop is an intuitive way for users to copy or move data around in an application, and is used in many desktop environments as a mechanism for copying data between applications. Drag and drop support in Qt is centered around the QDrag class that handles most of the details of a drag and drop operation.</p>
<p>The data to be transferred by the drag and drop operation is contained in a <a href="qmimedata.html">QMimeData</a> object. This is specified with the <a href="qdrag.html#setMimeData">setMimeData</a>() function in the following way:</p>
<pre>         QDrag *drag = new QDrag(this);
         QMimeData *mimeData = new QMimeData;

         mimeData-&gt;setText(commentEdit-&gt;toPlainText());
         drag-&gt;setMimeData(mimeData);</pre>
<p>Note that <a href="qdrag.html#setMimeData">setMimeData</a>() assigns ownership of the <a href="qmimedata.html">QMimeData</a> object to the QDrag object. The QDrag must be constructed on the heap with a parent <a href="qobject.html">QObject</a> to ensure that Qt can clean up after the drag and drop operation has been completed.</p>
<p>A pixmap can be used to represent the data while the drag is in progress, and will move with the cursor to the drop target. This pixmap typically shows an icon that represents the MIME type of the data being transferred, but any pixmap can be set with <a href="qdrag.html#setPixmap">setPixmap</a>(). Care must be taken to ensure that the pixmap is not too large. The cursor's hot spot can be given a position relative to the top-left corner of the pixmap with the <a href="qdrag.html#setHotSpot">setHotSpot</a>() function. The following code positions the pixmap so that the cursor's hot spot points to the center of its bottom edge:</p>
<pre>     drag-&gt;setHotSpot(QPoint(drag-&gt;pixmap().width()/2,
                             drag-&gt;pixmap().height()));</pre>
<p>The source and target widgets can be found with <a href="qdrag.html#source">source</a>() and <a href="qdrag.html#target">target</a>(). These functions are often used to determine whether drag and drop operations started and finished at the same widget, so that special behavior can be implemented.</p>
<p>QDrag only deals with the drag and drop operation itself. It is up to the developer to decide when a drag operation begins, and how a QDrag object should be constructed and used. For a given widget, it is often necessary to reimplement <a href="qwidget.html#mousePressEvent">mousePressEvent()</a> to determine whether the user has pressed a mouse button, and reimplement <a href="qwidget.html#mouseMoveEvent">mouseMoveEvent()</a> to check whether a QDrag is required.</p>
<p>See also <a href="dnd.html">Drag and Drop</a>, <a href="qclipboard.html">QClipboard</a>, <a href="qmimedata.html">QMimeData</a>, <a href="draganddrop-draggableicons.html">Draggable Icons Example</a>, <a href="draganddrop-draggabletext.html">Draggable Text Example</a>, <a href="draganddrop-dropsite.html">Drop Site Example</a>, and <a href="draganddrop-fridgemagnets.html">Fridge Magnets Example</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QDrag"></a>QDrag::QDrag ( <a href="qwidget.html">QWidget</a> * <i>dragSource</i> )</h3>
<p>Constructs a new drag object for the widget specified by <i>dragSource</i>.</p>
<h3 class="fn"><a name="dtor.QDrag"></a>QDrag::~QDrag ()</h3>
<p>Destroys the drag object.</p>
<h3 class="fn"><a name="actionChanged"></a>void QDrag::actionChanged ( <a href="qt.html#DropAction-enum">Qt::DropAction</a> <i>action</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the <i>action</i> associated with the drag changes.</p>
<p>See also <a href="qdrag.html#targetChanged">targetChanged</a>().</p>
<h3 class="fn"><a name="hotSpot"></a><a href="qpoint.html">QPoint</a> QDrag::hotSpot () const</h3>
<p>Returns the position of the hot spot relative to the top-left corner of the cursor.</p>
<p>See also <a href="qdrag.html#setHotSpot">setHotSpot</a>().</p>
<h3 class="fn"><a name="mimeData"></a><a href="qmimedata.html">QMimeData</a> * QDrag::mimeData () const</h3>
<p>Returns the MIME data that is encapsulated by the drag object.</p>
<p>See also <a href="qdrag.html#setMimeData">setMimeData</a>().</p>
<h3 class="fn"><a name="pixmap"></a><a href="qpixmap.html">QPixmap</a> QDrag::pixmap () const</h3>
<p>Returns the pixmap used to represent the data in a drag and drop operation.</p>
<p>See also <a href="qdrag.html#setPixmap">setPixmap</a>().</p>
<h3 class="fn"><a name="setDragCursor"></a>void QDrag::setDragCursor ( const <a href="qpixmap.html">QPixmap</a> &amp; <i>cursor</i>, <a href="qt.html#DropAction-enum">Qt::DropAction</a> <i>action</i> )</h3>
<p>Sets the drag <i>cursor</i> for the <i>action</i>. This allows you to override the default native cursors. To revert to using the native cursor for <i>action</i> pass in a null <a href="qpixmap.html">QPixmap</a> as <i>cursor</i>.</p>
<p>The <i>action</i> can only be CopyAction, MoveAction or LinkAction. All other values of DropAction are ignored.</p>
<h3 class="fn"><a name="setHotSpot"></a>void QDrag::setHotSpot ( const <a href="qpoint.html">QPoint</a> &amp; <i>hotspot</i> )</h3>
<p>Sets the position of the hot spot relative to the top-left corner of the pixmap used to the point specified by <i>hotspot</i>.</p>
<p>See also <a href="qdrag.html#hotSpot">hotSpot</a>().</p>
<h3 class="fn"><a name="setMimeData"></a>void QDrag::setMimeData ( <a href="qmimedata.html">QMimeData</a> * <i>data</i> )</h3>
<p>Sets the data to be sent to the given MIME <i>data</i>. Ownership of the data is transferred to the <a href="qdrag.html">QDrag</a> object.</p>
<p>See also <a href="qdrag.html#mimeData">mimeData</a>().</p>
<h3 class="fn"><a name="setPixmap"></a>void QDrag::setPixmap ( const <a href="qpixmap.html">QPixmap</a> &amp; <i>pixmap</i> )</h3>
<p>Sets <i>pixmap</i> as the pixmap used to represent the data in a drag and drop operation.</p>
<p>See also <a href="qdrag.html#pixmap">pixmap</a>().</p>
<h3 class="fn"><a name="source"></a><a href="qwidget.html">QWidget</a> * QDrag::source () const</h3>
<p>Returns the source of the drag object. This is the widget where the drag and drop operation originated.</p>
<h3 class="fn"><a name="start"></a><a href="qt.html#DropAction-enum">Qt::DropAction</a> QDrag::start ( <a href="qt.html#DropAction-enum">Qt::DropActions</a> <i>request</i> = Qt::CopyAction )</h3>
<p>Starts the drag and drop operation and returns a value indicating the requested drop action when it is completed. The drop actions that the user can choose from are specified in <i>request</i>. <a href="qt.html#DropAction-enum">Qt::CopyAction</a> is always allowed.</p>
<p><b>Note:</b> Although the drag and drop operation can take some time, this function does not block the event loop. Other events are still delivered to the application while the operation is performed.</p>
<h3 class="fn"><a name="target"></a><a href="qwidget.html">QWidget</a> * QDrag::target () const</h3>
<p>Returns the target of the drag and drop operation. This is the widget where the drag object was dropped.</p>
<h3 class="fn"><a name="targetChanged"></a>void QDrag::targetChanged ( <a href="qwidget.html">QWidget</a> * <i>newTarget</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the target of the drag and drop operation changes, with <i>newTarget</i> the new target.</p>
<p>See also <a href="qdrag.html#target">target</a>() and <a href="qdrag.html#actionChanged">actionChanged</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2006 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.2.1</div></td>
</tr></table></div></address></body>
</html>