Note that there are some explanatory texts on larger screens.

plurals
  1. PODrag and Drop of QListView Items
    primarykey
    data
    text
    <p>Please help me out to solve this.... I have a <code>QListView</code> on the Left side and a <code>QWidget</code> on the other side. In <code>QListView</code> i had added few items using <code>QStandardItem</code>. Now i want to Drag and Drop the <code>QListView</code> Items to the other side <code>QWidget</code> and i have to do the same with the <code>QWidget</code> also. I can drag and drop my <code>QListView</code> Items <em>inside the <code>QListView</code></em> itself by using</p> <pre><code>listView.setAcceptDrops(true); listView.setDragEnabled(true); listView.setDragDropMode(QAbstractItemView::InternalMove); </code></pre> <p>this is working fine inside the QListView alone. I want to Drag and Drop the QListView Items to the other Widget. How can i do this? I know that i have to handle the Events like </p> <pre><code>void dropEvent(QDropEvent *); void dragMoveEvent(QDragMoveEvent *); void dragEnterEvent(QDragEnterEvent *); void mousePressEvent(QMouseEvent *); </code></pre> <p>i just tried it like this</p> <pre><code>void Example::dragMoveEvent(QDragMoveEvent *e) { // The event needs to be accepted here e-&gt;accept(); } void Example::dragEnterEvent(QDragEnterEvent *e) { // Set the drop action to be the proposed action. e-&gt;acceptProposedAction(); } void Example::dropEvent(QDropEvent *e) { qDebug("Items Dropped"); } </code></pre> <p>As i just tried with some <strong>qDebug()</strong> , <em>this is Working when i drag an Item from my <code>QListView</code> and Drop it in the <code>QWidget</code></em> and am getting the output as <strong>"Items Dropped"</strong>. <em>But i dont know how to bring my exact <code>QListView</code>'s Items</em> here.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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