QTreeWidget drag and drop problem



  • 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!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.