QTreeWidget's InternalMove reverses order when moving multiple items
I used setDragDropMode(InternalMove) to enable the user to drag items around a QTreeWidget-derived tree in my application. The tree also has its selectionMode set to ExtendedSelection so the user can select multiple items to move at a time.
I was very surprised to see that the order of the items is reversed after the move, as shown in the images below. I select the three bottom items and move them above the first item:
!http://imageshack.us/a/img543/8596/q67f.png(internal move 1)!
...and I get a result like this:
!http://imageshack.us/a/img834/5346/d6a1.png(internal move 2)!
(I was expecting 2-3-4-1)
Why is this happening and is there anything I can do for the order to be preserved? I am using Qt 5.0.2.
Hello again neuviemep,
It looks like whoever created the multiple selected item used a stack to contain the items being dragged, then added they add all the items to a given position. There could be some sort of sort being called behind the scenes as well.
If you want to implement your own version of the movement, you could use a List or Queue that way you could insert the items in whatever order you want to.
I was hoping I wouldn't have to create my own movement implementation. Frankly, I don't see the rationale behind such a design choice and even more so the reason for it being the default and unchangeable. Maybe it's not a major hassle but still...