Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTreeWidget's InternalMove reverses order when moving multiple items

QTreeWidget's InternalMove reverses order when moving multiple items

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neuviemep
    wrote on last edited by
    #1

    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.
    Thanks!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Buckets
      wrote on last edited by
      #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.

      ba ba ba
      ba na na na

      1 Reply Last reply
      0
      • N Offline
        N Offline
        neuviemep
        wrote on last edited by
        #3

        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...

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved