Hello !
(Sorry for my english)

I am currently trying to make a drag & drop in a QTreeWidget. So I put the corresponding settings and the method dropEvent :

Qt Code:
  1. class TreeWidget : public QTreeWidget
  2. {
  3. protected:
  4.  
  5. virtual void dropEvent(QDropEvent *event) override
  6. {
  7. QModelIndex index = indexAt(event->pos());
  8. if (!index.isValid()) { // just in case
  9. event->setDropAction(Qt::IgnoreAction);
  10. return;
  11. }
  12.  
  13. QTreeWidgetItem* item = itemFromIndex(index);
  14. qDebug() << "drop on item" << item->text(0);
  15.  
  16. QTreeWidget::dropEvent(event);
  17. }
  18. };
  19.  
  20. int main()
  21. {
  22. TreeWidget *listWidget = new TreeWidget;
  23. listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
  24. listWidget->setDragEnabled(true);
  25. listWidget->viewport()->setAcceptDrops(true);
  26. listWidget->setDropIndicatorShown(true);
  27. listWidget->setDragDropMode(QAbstractItemView::InternalMove);
  28. }
To copy to clipboard, switch view to plain text mode 

But in my case, I would like to move only parent items. In the code, I get the destination item, but how get dragged item ?

Have I to overload a drag method ? Launch the drag myself from mousePressEvent ? What is the best way to do ?

Thanks !