View Full Version : I wanna drag and drop some files into QTreeView

27th September 2011, 10:44

I'm making messenger program such as MSN or Google Talk.
I have some problems on FileTransfer.
To send a file to someone, I need to drag and drop it on member(tree item) of qtreeview.
(There is a member list on QTreeView subclass.)

I set "setAcceptDrop" and... changed various properties.
But it is impossible to drag and drop a file.


thank you in advance.

27th September 2011, 15:50
In addition to setAcceptDrops( true ), you should process QEvent:: DragEnter and QEvent:: Drop events at least.
There are examples on this purpose in Qt (examples/draganddrop, http://doc.qt.nokia.com/latest/examples-draganddrop.html).

28th September 2011, 02:15
I have already tried to make setAcceptDrops true and describe DragEnteredEvent function.
But when dragging a file on QTreeView, mouse pointer shows me unavailable icon as below not plus icon.

and I found enter into DragEnteredEvent when a files is dragged on QTreeView but DropEvent doesn't occur.

28th September 2011, 08:57
Are you sure you accept QEvent::DragEnter (event->accept()) event and consume it for tree view?
Could you paste a piece of code here?

28th September 2011, 10:13
I have some missing codes.

I solved it. event->accept() should be inserted in DragEnter, DragMove event.

Thank you