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 drag and drop problem

QTreeWidget drag and drop problem

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.6k Views
  • 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.
  • mcphattyM Offline
    mcphattyM Offline
    mcphatty
    wrote on last edited by
    #1

    Hello!

    I've got a problem regarding drag and dropping inside a qtreewidget. I do internalmove and it does nearly what I want. There are 2 problems:

    1. I do not want that items can be dropped to the root layer. I tried to set the flags of the invisibleRootItem to disable dropping. It works basically. When I drop my item between two items there is the nice drop indicator and i can insert the item at this position. However where the item will be inserted depends on the y position of the item on the time of the drop. When the items y position is nearly the one of the item where it should be inserted the drop works correct. When moving the item at the same height to the left and dropping it there, then the item will suddenly become a top level item, which should not be possible. This is strange behaviour, why should it be possible to insert at a hierarchy level that is not the one of the items i am inserting at. I think this is only correct behaviour when inserting at the end of a hierarchy level when there are more than one possibility where the item could be inserted. like:
      @
      -Item1
      -Item2
      -Item3
      -Item4
      |-------Possibility 1: Item2 is parent
      -Item5
      @
      @
      -Item1
      -Item2
      -Item3
      -Item4
      |-------Possibility 2: Item1 is parent
      -Item5
      @

    BUT NOT:

    @
    -Item1
    -Item2
    -Item3
    |------------ Root gets parent!
    -Item4
    -Item5
    @

    It makes me mad. Does someone know how to get rid of that?

    1. Is there a way to find out in dropEvent what the new parent will be and at what index of the parent the item will land?

    Thanks!

    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