Results 1 to 16 of 16

Thread: How to get Qmodelindex from mimedata in drop event for tree?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2015
    Posts
    18
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How to get Qmodelindex from mimedata in drop event for tree?

    How can achieve drag and drop for tree than?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to get Qmodelindex from mimedata in drop event for tree?

    As I said earlier, you could store the dragged index in a persistant model index member and access that on drop.
    Or you encode the drag object in the mime data such that you can get all the necessary information back.

    Cheers,
    _

  3. #3
    Join Date
    Oct 2015
    Posts
    18
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How to get Qmodelindex from mimedata in drop event for tree?

    I also thought about same points .... sure i will try and keep posted about it.

    For second point i think i need to do recursion, right?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to get Qmodelindex from mimedata in drop event for tree?

    That depends on your tree/data.

    If it can't change due to outside events during drag&drop, then you only need to know the "root" of the subtree you are dragging.

    Cheers,
    _

  5. #5
    Join Date
    Oct 2015
    Posts
    18
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How to get Qmodelindex from mimedata in drop event for tree?

    Ya true, but what if i need only those child which are dragged, i need to maintain some kind of lit or vector of its id's right? for this i need to do recursion.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to get Qmodelindex from mimedata in drop event for tree?

    If that is what you need then that is what you need.

    E.g. if you drag a directory in a file system tree, the only thing you would need to know is the path of that directory, not for any of its children.

    But if your data requires you to know the full subtree, then that is what you need to have access to.

    Cheers,
    _

Similar Threads

  1. Event Filter doesnt work on Drop Event
    By DNW in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2015, 06:55
  2. drag and drop of tree item
    By sajis997 in forum Qt Programming
    Replies: 0
    Last Post: 14th December 2011, 22:33
  3. drag and drop in only one hierarchy of the tree widget
    By fulbay in forum Qt Programming
    Replies: 0
    Last Post: 17th December 2010, 15:57
  4. Drag and Drop for tree model
    By frank100 in forum Qt Programming
    Replies: 5
    Last Post: 8th December 2010, 19:21
  5. Drag and Drop MimeData
    By Zephro in forum Qt Programming
    Replies: 10
    Last Post: 16th May 2006, 19:20

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.