Unsolved How to Drag & Drop from QFileSystemModel QTreeView to Custom QTreeView
-
Hi Everybody,
I have got a custom QTreeView which represents a folder structure with feature of internal drag & drop (based on Full drag and drop support in QTreeView).
I have got an other QTreeView which has got a QFileSystemModel model.
I would like to implement drag from QFileSystemModel QTreeView to Custom QTreeView.
It is only a one-way "channel", so i don't want to drag an item from Custom QTreeView to QFileSystemModel QTreeView.Further informations:
- acceptDrops property is true both of them
- showDropIndicator property is true both of them
- dragEnabled property is true both of them
- dragDropMode property is CopyAction both of them
Custom QTreeView's model has got the next overridden methods:
Qt::DropActions TreeModel::supportedDropActions() const { return Qt::MoveAction; } Qt::DropActions TreeModel::supportedDragActions() const { return Qt::MoveAction; } Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const { if (!index.isValid()) { return Qt::ItemIsDropEnabled; } return QAbstractItemModel::flags(index) | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; }
How can i drag(copy) an item from QFileSystemModel QTreeView to Custom QTreeView?
BR,
Peter -
Hi,
Take a look at the drag and drop part of the model view programming chapter in Qt's documentation.