PDA

View Full Version : QTreeWidget Drag and Drop InternalMove problems



dysplaced
29th June 2012, 12:43
I am using a QTreeWidget with Drag and Drop operations and dragDropMode set to InternalMove.
For the most part, this works as expected, with one exception:

I want to allow dropping only for certain items, depending on the dragged item. I have overridden dragMoveEvent to only accept events where my constraints hold. This works, except for one constraint: I do not want it to be possible for an item to be dragged to root level. I do not know how to achieve this.

For my other constraints, I use itemAt(event.pos()) to get the target item. However, when I drag to a position just above a root level item (in the GUI, the root item is no longer marked – instead there is a horizontal line above it), this also gives me the root item, so I can’t use it to decide whether I will be dragging to root level or into a root item.

This is supposed to be allowed and works fine:
7910

This is supposed to be forbidden, but I don’t see a way to distinguish it from the first case:
7911