Hi,

sorry it took so long. Here is my (very simple) tree widget


----------------------------------------------------------------------------
Qt Code:
  1. #include "myQTTreeWidget.h"
  2.  
  3. #include <QDragEnterEvent>
  4. #include <QDragMoveEvent>
  5. #include <QList>
  6.  
  7.  
  8. myQTTreeWidget::myQTTreeWidget(QWidget* parent)
  9. : QTreeWidget(parent)
  10. {
  11. setAcceptDrops(true);
  12. setDragEnabled(true);
  13.  
  14. setDragDropMode(QAbstractItemView::DragDrop);
  15. setSelectionMode(QAbstractItemView::ExtendedSelection);
  16. setEditTriggers(QAbstractItemView::SelectedClicked);
  17.  
  18. setHeaderLabel("Name");
  19. setColumnCount(1);
  20.  
  21. QTreeWidgetItem *item1 = new QTreeWidgetItem(this);
  22. QTreeWidgetItem *item2 = new QTreeWidgetItem(this);
  23. QTreeWidgetItem *item3 = new QTreeWidgetItem(this);
  24. QTreeWidgetItem *item4 = new QTreeWidgetItem(this);
  25.  
  26. item1->setText(0,"hello");
  27. item2->setText(0,"world!");
  28. item3->setText(0,"whats");
  29. item4->setText(0,"up?");
  30.  
  31. }
  32.  
  33. myQTTreeWidget::~myQTTreeWidget()
  34. {
  35. }
  36.  
  37. void myQTTreeWidget::dragEnterEvent(QDragEnterEvent *e)
  38. {
  39. e->accept();
  40. }
  41.  
  42. void myQTTreeWidget::dragMoveEvent(QDragMoveEvent *e)
  43. {
  44. e->accept();
  45. }
  46.  
  47. QMimeData *myQTTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const
  48. {
  49. return new QMimeData;
  50. }
  51.  
  52. bool myQTTreeWidget::dropMimeData ( QTreeWidgetItem * newParentPtr, int index, const QMimeData * data, Qt::DropAction action )
  53. {
  54. return true;
  55. }
  56.  
  57. Qt::DropActions myQTTreeWidget::supportedDropActions () const
  58. {
  59. return Qt::CopyAction|Qt::MoveAction;
  60. }
To copy to clipboard, switch view to plain text mode 
-----------------------------------------------------------------------------

If you want to reproduce the behaviour, you can place a breakpoint into dropMimeData (or some kind of fprintf(...) output ). You will see that this function is called if you try to drag & drop one of the items (without pressing Shift!). But it is not called if you press the Shift key while you're dragging/dropping the item. If you try to drag&drop an item without pressing Shift - nothing happens after dropping the item (that's ok, the drop function is empty). If you drag&drop an item while the Shift key is pressed, then the item is moved after dropping it (wherever this behaviour is implemented).

Maybe there is something totally wrong with my code. Maybe I made something very stupid? Any suggestion is very welcome.

Thanks, take care