PDA

View Full Version : dragNdrop between QTreeWidget and QTextEdit



jh
18th September 2006, 15:19
hi,

how can i drag an item from a qtreewidget to a qtextedit?
dragging is enabled to the qtreewidget, but it's not possible to
drop it (insert the text of the item) on the qtextedit.

best regards,
jh

wysota
18th September 2006, 15:21
You should reimplement events in the text edit object to handle the drop. If the drag is a textual one (it has mime text/plain), it should work out of the box, provided that you have told the text edit to accept drops.

jh
18th September 2006, 15:28
the text should be copied from the qtreewidget to the
qtextedit. so how can i provide a text/plain mime object to be
dragged from the treeview?

jh

wysota
18th September 2006, 15:36
There is no easy way of doing that for a tree widget. You should use a tree view with a custom model, where you could implement the drag mime easily. In your case it should be easier to reimplement dragEnterEvent and dropEvent for the text edit to handle the drag from a tree widget (just check what mime it uses, for example by using the "droptarget" example from Qt bundle).