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. Drag&Drop between Treeviews replaces target item
QtWS25 Last Chance

Drag&Drop between Treeviews replaces target item

Scheduled Pinned Locked Moved Unsolved General and Desktop
drag&droptreeview
2 Posts 2 Posters 636 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.
  • F Offline
    F Offline
    flautzr
    wrote on 21 Jun 2018, 07:36 last edited by flautzr
    #1

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 Jun 2018, 21:10 last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      21 Jun 2018, 07:36

      • Login

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