I have subclasses of QTreeView
and QAbstractItemModel
and currently I'm using drag-drop to move items from one parent index to another. I want to also add the ability to rearrange the order of items within the same parent index. When the user drops an item in-between two other items, I need to determine whether the drop should be into, or in-between them. I would also like to draw a dark line between the two items as the mouse is moved, to hint as to what will occur, similar to many other tree-type views (e.g. file explorers on most operating systems) as in the attached pictures:
Drag into an existing item:
Insert between two existing items:
Does Qt automate this part of drag/drop behavior, or do I have to manually calculate the mouse position relative to the edge of the tree item? Also, how can I draw a temporary line between two items in the QTreeView
?