views:

77

answers:

1

I'm trying to, inside a dropevent method, find out which widget was just dropped. I tried looking at the docs, but they only have commands for images and text. How do I access both the item just dropped and which widget it was dropped on?(this is drag and drop inside of a QTreeWidget)

A: 

By default, Qt is limited to darg & drop text and images but this behaviour can be extended by adding new MIME Type.

You can find an interesting example of drag & drop using alternate data type at http://doc.trolltech.com/4.6/draganddrop-fridgemagnets.html. This example can be extended to support drag & drop of widgets.

You can find the QModelIndex of the item receiving the drop by giving the QDropEvent::pos() parameter to the QAbstractItemView::indexAt() method of the QTreeView. This gives you the opportunity to find the actual widget if that is what you want.

Lohrun