Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You just implement <a href="http://doc.trolltech.com/latest/qdrag.html#details" rel="nofollow noreferrer">the drag part</a>. You don't need to know where the drop happen because the application receiving it will handle it and decide where to store your file.</p> <p>You create a <a href="http://doc.trolltech.com/latest/qmimedata.html#setData" rel="nofollow noreferrer">QMimeData</a>, not sure which type but from what i saw <a href="http://doc.trolltech.com/latest/dnd.html#interoperating-with-other-applications" rel="nofollow noreferrer">here</a> and <a href="http://www.freedesktop.org/wiki/Specifications/XDS" rel="nofollow noreferrer">here</a>, maybe "application/octet-stream" with your file as data in a QByteArray or "text/uri-list" with url to your file.</p> <p>You create a QDrag, and use its setMimeData() method and exec() (not sure about which QT::DropAction to choose).</p> <p>Here is an example (disclamer : i did it with color not files) :</p> <pre><code>void DraggedWidget::mousePressEvent(QMouseEvent *event) { if (event-&gt;button() == Qt::LeftButton) start_pos = event-&gt;pos(); } void DraggedWidget::mouseMoveEvent(QMouseEvent *event) { if (event-&gt;buttons() &amp; Qt::LeftButton) { int distance = (event-&gt;pos() - start_pos).manhattanLength(); if (distance &gt;= QApplication::startDragDistance()) { /* Drag */ QMimeData *mime_data = new QMimeData; mime_data-&gt;setData( ... ); QDrag *drag = new QDrag(this); drag-&gt;setMimeData(mime_data); drag-&gt;exec(Qt::CopyAction); } } } </code></pre> <p>Sorry it's quite incomplete, i hope it helps a little.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload