PDA

View Full Version : Drag and Drop (drop example)



din9
23rd January 2006, 15:05
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?

:confused:

Thanks.
(I'm on Qt 3.3.3)

wysota
23rd January 2006, 19:03
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.