<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qevent.cpp --> <title>QDropEvent Class | Qt GUI 5.12.2</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="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QDropEvent</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.12.2 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="#public-functions">Public Functions</a></li> <li class="level1"><a href="#protected-variables">Protected Variables</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">QDropEvent Class</h1> <!-- $$$QDropEvent-brief --> <p>The <a href="qdropevent.html">QDropEvent</a> class provides an event which is sent when a drag and drop action is completed. <a href="#details">More...</a></p> <!-- @@@QDropEvent --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QDropEvent></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="../qtcore/qevent.html">QEvent</a></td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="qdragmoveevent.html">QDragMoveEvent</a></p> </td></tr></table></div><ul> <li><a href="qdropevent-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#QDropEvent">QDropEvent</a></b>(const QPointF &<i>pos</i>, Qt::DropActions <i>actions</i>, const QMimeData *<i>data</i>, Qt::MouseButtons <i>buttons</i>, Qt::KeyboardModifiers <i>modifiers</i>, QEvent::Type <i>type</i> = Drop)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#acceptProposedAction">acceptProposedAction</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::DropAction </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#dropAction">dropAction</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::KeyboardModifiers </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#keyboardModifiers">keyboardModifiers</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QMimeData *</td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#mimeData">mimeData</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::MouseButtons </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#mouseButtons">mouseButtons</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#pos">pos</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QPointF &</td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#posF">posF</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::DropActions </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#possibleActions">possibleActions</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::DropAction </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#proposedAction">proposedAction</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#setDropAction">setDropAction</a></b>(Qt::DropAction <i>action</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QObject *</td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#source">source</a></b>() const</td></tr> </table></div> <ul> <li class="fn">6 public functions inherited from <a href="../qtcore/qevent.html#public-functions">QEvent</a></li> </ul> <a name="protected-variables"></a> <h2 id="protected-variables">Protected Variables</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Qt::DropActions </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#act-var">act</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::DropAction </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#default_action-var">default_action</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::DropAction </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#drop_action-var">drop_action</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QMimeData *</td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#mdata-var">mdata</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::KeyboardModifiers </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#modState-var">modState</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::MouseButtons </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#mouseState-var">mouseState</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPointF </td><td class="memItemRight bottomAlign"><b><a href="qdropevent.html#p-var">p</a></b></td></tr> </table></div> <h3>Additional Inherited Members</h3> <ul> <li class="fn">1 property inherited from <a href="../qtcore/qevent.html#properties">QEvent</a></li> <li class="fn">1 static public member inherited from <a href="../qtcore/qevent.html#static-public-members">QEvent</a></li> </ul> <a name="details"></a> <!-- $$$QDropEvent-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qdropevent.html">QDropEvent</a> class provides an event which is sent when a drag and drop action is completed.</p> <p>When a widget <a href="../qtwidgets/qwidget.html#acceptDrops-prop">accepts drop events</a>, it will receive this event if it has accepted the most recent <a href="qdragenterevent.html">QDragEnterEvent</a> or <a href="qdragmoveevent.html">QDragMoveEvent</a> sent to it.</p> <p>The drop event contains a proposed action, available from <a href="qdropevent.html#proposedAction">proposedAction</a>(), for the widget to either accept or ignore. If the action can be handled by the widget, you should call the <a href="qdropevent.html#acceptProposedAction">acceptProposedAction</a>() function. Since the proposed action can be a combination of <a href="../qtcore/qt.html#DropAction-enum">Qt::DropAction</a> values, it may be useful to either select one of these values as a default action or ask the user to select their preferred action.</p> <p>If the proposed drop action is not suitable, perhaps because your custom widget does not support that action, you can replace it with any of the <a href="qdropevent.html#possibleActions">possible drop actions</a> by calling <a href="qdropevent.html#setDropAction">setDropAction</a>() with your preferred action. If you set a value that is not present in the bitwise OR combination of values returned by <a href="qdropevent.html#possibleActions">possibleActions</a>(), the default copy action will be used. Once a replacement drop action has been set, call <a href="../qtcore/qevent.html#accept">accept</a>() instead of <a href="qdropevent.html#acceptProposedAction">acceptProposedAction</a>() to complete the drop operation.</p> <p>The <a href="qdropevent.html#mimeData">mimeData</a>() function provides the data dropped on the widget in a <a href="../qtcore/qmimedata.html">QMimeData</a> object. This contains information about the MIME type of the data in addition to the data itself.</p> </div> <p><b>See also </b><a href="../qtcore/qmimedata.html">QMimeData</a>, <a href="qdrag.html">QDrag</a>, and <a href="dnd.html">Drag and Drop</a>.</p> <!-- @@@QDropEvent --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QDropEvent[overload1]$$$QDropEventconstQPointF&Qt::DropActionsconstQMimeData*Qt::MouseButtonsQt::KeyboardModifiersQEvent::Type --> <h3 class="fn" id="QDropEvent"><a name="QDropEvent"></a>QDropEvent::<span class="name">QDropEvent</span>(const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &<i>pos</i>, <span class="type"><a href="../qtcore/qt.html#DropAction-enum">Qt::DropActions</a></span> <i>actions</i>, const <span class="type"><a href="../qtcore/qmimedata.html">QMimeData</a></span> *<i>data</i>, <span class="type"><a href="../qtcore/qt.html#MouseButton-enum">Qt::MouseButtons</a></span> <i>buttons</i>, <span class="type"><a href="../qtcore/qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a></span> <i>modifiers</i>, <span class="type"><a href="../qtcore/qevent.html#Type-enum">QEvent::Type</a></span> <i>type</i> = Drop)</h3> <p>Constructs a drop event of a certain <i>type</i> corresponding to a drop at the point specified by <i>pos</i> in the destination widget's coordinate system.</p> <p>The <i>actions</i> indicate which types of drag and drop operation can be performed, and the drag data is stored as MIME-encoded data in <i>data</i>.</p> <p>The states of the mouse buttons and keyboard modifiers at the time of the drop are specified by <i>buttons</i> and <i>modifiers</i>.</p> <!-- @@@QDropEvent --> <!-- $$$acceptProposedAction[overload1]$$$acceptProposedAction --> <h3 class="fn" id="acceptProposedAction"><a name="acceptProposedAction"></a><span class="type">void</span> QDropEvent::<span class="name">acceptProposedAction</span>()</h3> <p>Sets the drop action to be the proposed action.</p> <p><b>See also </b><a href="qdropevent.html#setDropAction">setDropAction</a>(), <a href="qdropevent.html#proposedAction">proposedAction</a>(), and <a href="../qtcore/qevent.html#accept">accept</a>().</p> <!-- @@@acceptProposedAction --> <!-- $$$dropAction[overload1]$$$dropAction --> <h3 class="fn" id="dropAction"><a name="dropAction"></a><span class="type"><a href="../qtcore/qt.html#DropAction-enum">Qt::DropAction</a></span> QDropEvent::<span class="name">dropAction</span>() const</h3> <p>Returns the action to be performed on the data by the target. This may be different from the action supplied in <a href="qdropevent.html#proposedAction">proposedAction</a>() if you have called <a href="qdropevent.html#setDropAction">setDropAction</a>() to explicitly choose a drop action.</p> <p><b>See also </b><a href="qdropevent.html#setDropAction">setDropAction</a>().</p> <!-- @@@dropAction --> <!-- $$$keyboardModifiers[overload1]$$$keyboardModifiers --> <h3 class="fn" id="keyboardModifiers"><a name="keyboardModifiers"></a><span class="type"><a href="../qtcore/qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a></span> QDropEvent::<span class="name">keyboardModifiers</span>() const</h3> <p>Returns the modifier keys that are pressed.</p> <!-- @@@keyboardModifiers --> <!-- $$$mimeData[overload1]$$$mimeData --> <h3 class="fn" id="mimeData"><a name="mimeData"></a>const <span class="type"><a href="../qtcore/qmimedata.html">QMimeData</a></span> *QDropEvent::<span class="name">mimeData</span>() const</h3> <p>Returns the data that was dropped on the widget and its associated MIME type information.</p> <!-- @@@mimeData --> <!-- $$$mouseButtons[overload1]$$$mouseButtons --> <h3 class="fn" id="mouseButtons"><a name="mouseButtons"></a><span class="type"><a href="../qtcore/qt.html#MouseButton-enum">Qt::MouseButtons</a></span> QDropEvent::<span class="name">mouseButtons</span>() const</h3> <p>Returns the mouse buttons that are pressed..</p> <!-- @@@mouseButtons --> <!-- $$$pos[overload1]$$$pos --> <h3 class="fn" id="pos"><a name="pos"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QDropEvent::<span class="name">pos</span>() const</h3> <p>Returns the position where the drop was made.</p> <!-- @@@pos --> <!-- $$$posF[overload1]$$$posF --> <h3 class="fn" id="posF"><a name="posF"></a>const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &QDropEvent::<span class="name">posF</span>() const</h3> <p>Returns the position where the drop was made.</p> <!-- @@@posF --> <!-- $$$possibleActions[overload1]$$$possibleActions --> <h3 class="fn" id="possibleActions"><a name="possibleActions"></a><span class="type"><a href="../qtcore/qt.html#DropAction-enum">Qt::DropActions</a></span> QDropEvent::<span class="name">possibleActions</span>() const</h3> <p>Returns an OR-combination of possible drop actions.</p> <p><b>See also </b><a href="qdropevent.html#dropAction">dropAction</a>().</p> <!-- @@@possibleActions --> <!-- $$$proposedAction[overload1]$$$proposedAction --> <h3 class="fn" id="proposedAction"><a name="proposedAction"></a><span class="type"><a href="../qtcore/qt.html#DropAction-enum">Qt::DropAction</a></span> QDropEvent::<span class="name">proposedAction</span>() const</h3> <p>Returns the proposed drop action.</p> <p><b>See also </b><a href="qdropevent.html#dropAction">dropAction</a>().</p> <!-- @@@proposedAction --> <!-- $$$setDropAction[overload1]$$$setDropActionQt::DropAction --> <h3 class="fn" id="setDropAction"><a name="setDropAction"></a><span class="type">void</span> QDropEvent::<span class="name">setDropAction</span>(<span class="type"><a href="../qtcore/qt.html#DropAction-enum">Qt::DropAction</a></span> <i>action</i>)</h3> <p>Sets the <i>action</i> to be performed on the data by the target. Use this to override the <a href="qdropevent.html#proposedAction">proposed action</a> with one of the <a href="qdropevent.html#possibleActions">possible actions</a>.</p> <p>If you set a drop action that is not one of the possible actions, the drag and drop operation will default to a copy operation.</p> <p>Once you have supplied a replacement drop action, call <a href="../qtcore/qevent.html#accept">accept</a>() instead of <a href="qdropevent.html#acceptProposedAction">acceptProposedAction</a>().</p> <p><b>See also </b><a href="qdropevent.html#dropAction">dropAction</a>().</p> <!-- @@@setDropAction --> <!-- $$$source[overload1]$$$source --> <h3 class="fn" id="source"><a name="source"></a><span class="type"><a href="../qtcore/qobject.html">QObject</a></span> *QDropEvent::<span class="name">source</span>() const</h3> <p>If the source of the drag operation is a widget in this application, this function returns that source; otherwise it returns <code>nullptr</code>. The source of the operation is the first parameter to the <a href="qdrag.html">QDrag</a> object used instantiate the drag.</p> <p>This is useful if your widget needs special behavior when dragging to itself.</p> <p><b>See also </b><a href="qdrag.html#QDrag">QDrag::QDrag</a>().</p> <!-- @@@source --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</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>