There's a lot of discussion of DragNDrop with QTreeView widgets but I can't seem to find the "golden nugget" I need to get the basic functionality to work right. New entries get created in my tree but they have empty data. I believe it is a problem with my dropMimeData() method, but where?

I've startetd with the "editabletreemodel" example (see http://doc.trolltech.com/4.3/itemvie...treemodel.html) and made the following changes:

In the constructor for mainwindow I've added:
Qt Code:
  1. view->setDragEnabled(true);
  2. view->setDragDropMode(QAbstractItemView::InternalMove);
  3. view->setAcceptDrops(true);
  4. view->setDropIndicatorShown(true);
To copy to clipboard, switch view to plain text mode 

In the TreeModel I've modified the flags() method to return:
Qt Code:
  1. Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
To copy to clipboard, switch view to plain text mode 

and added these two methods to TreeModel:
Qt Code:
  1. Qt::DropActions TreeModel::supportedDropActions() const
  2. {
  3. return Qt::CopyAction | Qt::MoveAction;
  4. }
  5.  
  6. bool TreeModel::dropMimeData(const QMimeData *data,
  7. Qt::DropAction action,
  8. int row, int column,
  9. const QModelIndex &parent)
  10. {
  11. if (QAbstractItemModel::dropMimeData(data, action, row, column, parent)) {
  12. return true;
  13. }
  14. return false;
  15. }
To copy to clipboard, switch view to plain text mode 

When running this code and doing a drag and drop new (empty) items are created in the appropriate destination. I'm just not getting the actual data elements copied over. Should I somehow be able to parse the "application/x-qabstractitemmodeldatalist" data myself? Is it necessary to implement TreeModel::mimeData() and create my own mime types?

What are other people doing for drag and drop with QTreeView?