Drag&Drop between Treeviews replaces target item



  • Hi,
    i use a dialogue window with 2 separate tree views. It is only possible to drag an item from the right tree to the left, no internal drag&drop either. In order to make drag&drop work, the functions dropMimeData, insertRows and removeRows are overwritten in the model, as well as supportedDragActions, which is only allowing Qt::MoveAction.
    Everything works fine, but when i drag an item from the right tree onto an folder in the left tree, the folder gets replaced by that item automatically.
    This is not the intended outcome, i want to handle the insertion myself.
    In my understanding, the functions removeRows and insertRows are responsible for handling the way the dragged item is processed, but even ehen nothing happens in them, the target gets replaced.
    I cant find the reason for this behaviour. In order to find it, i did overwrite dropEvent as well, but without calling dropMimeData, the functions removeRows and insertRows are not called.
    The problem is that I need those to determine which items were dragged and where. How can i find out what item is being dragged and where while preventing the target from being replaced?

    thanks in advance
    Jonathan


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What version of Qt are you using ?
    On what OS ?
    With what compiler ?
    Can you provide a minimal compilable example that shows that behaviour ?


Log in to reply
 

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