Results 1 to 2 of 2

Thread: Drag and Drop (drop example)

  1. #1
    Join Date
    Jan 2006
    Qt products

    Default Drag and Drop (drop example)


    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?

    (I'm on Qt 3.3.3)

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    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: 21st January 2009, 00:02
  2. drag and drop QToolButton in QToolBar
    By NBilal in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 21:11
  3. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 17:56
  4. Drag & Drop when parent and childs accept drops?
    By gri in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 10:00
  5. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 17:41


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.