Hi,

after a lot of research and trial and error, i hit a dead end. What i want is a QTreeView that has drag&drop enabled, but only file elements inside should be dragable (and not accept drops) and only folder elements should accept drops, and not be dragable.

if i configure the QTreeView like this
Qt Code:
  1. ptrTreeView->setDragEnabled(true);
  2. ptrTreeView->setAcceptDrops(true);
To copy to clipboard, switch view to plain text mode 

or like this
Qt Code:
  1. ptrTreeView->setDragDropMode(QAbstractItemView::DragDropMode::DragDrop);
To copy to clipboard, switch view to plain text mode 

and set the items to
Qt Code:
  1. ptrFileItem->setDragEnabled(true);
  2. ptrFileItem->setDropEnabled(false);
To copy to clipboard, switch view to plain text mode 

and the folders to
Qt Code:
  1. ptrFolderItem->setDragEnabled(false);
  2. ptrFolderItem->setDropEnabled(true);
To copy to clipboard, switch view to plain text mode 

every item is still drag and dropable as if the the configuration of the tree overrides the individual configuration of the items. Do you guys know of a way where this is possible?

Another approach I tried is to let every item have both drag&drop ability but to modify the drop indicator and block/allow the actual drag&dropping in the drag&drop functions, but i did not succeed wit that either.
I created a custom model class derived from QStandardItemModel in which the flags fundtion is overridden
Qt Code:
  1. class MyModel: public QStandardItemModel
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. MyModel(QWidget *parent = Q_NULLPTR) : QStandardItemModel(parent) {};
  7.  
  8. virtual Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
  9. }
To copy to clipboard, switch view to plain text mode 

In the flags function i analyzed the current Item and modified the Qt::ItemFlags so that Drag and Drop was enabled/disabled but still the drop indicator was shown while hovering over all the file/folder items. Is this approach wrong and if so, do you know of a working one?