Results 1 to 2 of 2

Thread: Drag and Drop (drop example)

  1. #1
    Join Date
    Jan 2006
    Posts
    1
    Qt products
    Qt3
    Platforms
    Windows

    Default Drag and Drop (drop example)

    Hi!

    I have to drag-drop QListViewItem-s from one QListView to another and vice versa.

    In all of QT manual examples there is no implementation of such drop.
    How can I drop QListViewItem object, not Text or Image?

    ... and after dropping to one QListView, how can I remove dropped item from former
    parent QListView?



    Thanks.
    (I'm on Qt 3.3.3)

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag and Drop (drop example)

    You have to encode the item into some pseudo mime-type (like text/x-my-custom-listview-mime) and make both listviews accept it. Subclass QTextDrag or QDragObject and implement your mime-type there. If you're using just text data, it is better to use QTextDrag and encode the data in a tab-separated-values format (column1\tcolumn2\tcolumn3\tetc.). Then make both widgets aware of the mime-type and handle them in the drop event.

    About the second question:
    If the target understands the Move action, the target is responsible for both the copy and delete operations and the source will not attempt to delete the data itself.

Similar Threads

  1. Drag and Drop QTableWidget in UI file.
    By tpf80 in forum Qt Programming
    Replies: 3
    Last Post: 20th January 2009, 23:02
  2. drag and drop QToolButton in QToolBar
    By NBilal in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:11
  3. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 16:56
  4. Drag & Drop when parent and childs accept drops?
    By gri in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 09:00
  5. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 16:41

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.