I'm having problems getting my drag and drop working for a QTreeView. Everything was working fine a couple of months ago but somewhere along the line it stopped working. I've managed to get the drag and drop itself working again, but I do not get a drop indicator, and the tree doesn't expand regardless of how long I hover the drop over it.

My tree view code looks like this:
Qt Code:
  1. MyTreeView::MyTreeView(QWidget *parent) :
  2. QTreeView(parent)
  3. {
  4. setSelectionMode(QAbstractItemView::SingleSelection);
  5. viewport()->setAcceptDrops(true);
  6. setDragEnabled(true);
  7. setDropIndicatorShown(true);
  8. setAutoExpandDelay(0);
  9. setIndentation(16);
  10. }
  11.  
  12. void MyTreeView::dragEnterEvent(QDragEnterEvent *event)
  13. {
  14. event->acceptProposedAction();
  15. }
  16.  
  17. void MyTreeView::dragMoveEvent(QDragMoveEvent *event)
  18. {
  19. event->acceptProposedAction();
  20. }
To copy to clipboard, switch view to plain text mode 

I don't know if this code matters in this case, but this is my subclassed standard item model:
Qt Code:
  1. MyItemModel::MyItemModel(QWidget *topWidget, QObject *parent) :
  2. {
  3. w = topWidget;
  4. }
  5.  
  6. Qt::DropActions MyItemModel::supportedDropActions() const
  7. {
  8. return Qt::CopyAction | Qt::MoveAction;
  9. }
  10.  
  11. Qt::ItemFlags MyItemModel::flags(const QModelIndex &index) const
  12. {
  13. QString type = index.data(FileTypeRole).toString();
  14.  
  15. // We should only be able to drop onto folders.
  16. if (type != "File" && type != "ImageFile" && index.isValid())
  17. return Qt::ItemIsDropEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled;
  18. else
  19. return Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled;
  20. }
  21.  
  22. bool MyItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
  23. {
  24. // this all works fine, so I'm cutting it for brevity.
  25. }
  26.  
  27. QStringList MyItemModel::mimeTypes () const
  28. {
  29. QStringList qstrList;
  30. // This is a list of the accepted mime types for dropping.
  31. qstrList.append("text/uri-list");
  32. return qstrList;
  33. }
To copy to clipboard, switch view to plain text mode 

Everything works as far and drag and drop goes, but it makes it difficult to control where you are dropping with a visual indicator and without the tree expanding for you. Any tips on how to fix this would be greatly appreciated.