Results 1 to 2 of 2

Thread: Preserving structure in QTreeView drag and drop

  1. #1
    Tito Serenti Guest

    Default Preserving structure in QTreeView drag and drop

    Hi, I have reimplemented my own QTreeView and my own model, and enabled drag and drop following the example in the documentation (using text meta data). The problem I'm having is in preserving the structure of the tree as I drag and drop the items (from the same tree). In the documentation the example simply drops the list of items, but the parent-child relationship is lost. How do I insert the dropped items and preserve their tree structure?

    I tried accessing the selection in the tree instead of passing the info via meta data, because then I could just iterate the tree and insert the items that are selected (since the selected items are the ones being dragged and dropped. But selectionModel() does not return items in their proper order, so the folders are all grouped together, the files are grouped together and I can't get the parent-child relationship from that either.

    Any ideas?

  2. #2
    Tito Serenti Guest

    Default Re: Preserving structure in QTreeView drag and drop

    Never mind, I found a solution. I used a recursive function to get the list of selected items and then a recursive function to insert them when dropped (the drag and drop is limited to the same tree).

Similar Threads

  1. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 16:56
  2. Drag and drop in QTreeView
    By Valheru in forum Qt Programming
    Replies: 3
    Last Post: 27th July 2008, 09:36
  3. Drag and Drop on Whitespace of QTreeView
    By T1c4L in forum Qt Programming
    Replies: 6
    Last Post: 14th May 2008, 13:29
  4. Drag & drop items on the same QTreeView
    By wind in forum Qt Programming
    Replies: 2
    Last Post: 11th October 2006, 14:29
  5. Drag & drop for QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2006, 14:32

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.