View Full Version : QTreeView Drag and Drop: Copying heirarchy

12th August 2011, 09:54

I have two QTreeViews side by side connected to a single QAbstractItemModel through two QSortFilterProxyModel each implementing a distinct filter on the model. I have implemented the methods required for DnD.

I can drag an item from one view, drop it into the other view and create a copy of the item data using the setItemData() method. However, if the item dragged is a parent of other items in the model I can't get the children copied as well (only the parent gets copied with no children inserted below). I've tried the linkAction but that doesn't seem to help either.

Does the model DnD mechanism support copying/moving whole hierarchies of items out of the box? If not, can anyone suggest how I might go about it?


12th August 2011, 15:10
I eventually have managed to do this by storing the source item in the model, which I then accessed when doing the copy, to copy its descendants and thereof. Strange Qt doesn't support this type of deep copy...