QTreeView Drag&Drop behaviour and how to disable drop indicator
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
Code:
ptrTreeView->setDragEnabled(true);
ptrTreeView->setAcceptDrops(true);
or like this
and set the items to
Code:
ptrFileItem->setDragEnabled(true);
ptrFileItem->setDropEnabled(false);
and the folders to
Code:
ptrFolderItem->setDragEnabled(false);
ptrFolderItem->setDropEnabled(true);
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
Code:
{
Q_OBJECT
public:
virtual Qt
::ItemFlags flags
(const QModelIndex &index
) const Q_DECL_OVERRIDE;
}
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?