PDA

View Full Version : Drag and Drop in QT4



batileon
9th December 2008, 08:24
I m porting code from QT3 to QT4

I have a widget with 2 frames, one with some drag-able icons, and another a ListView tree
In the past(QT3), I can drag the icon to the ListView tree. However after porting to QT4, I can't drag that!(seems the area of the ListView does not allow the icon to drag in)

Can anyone tell me why and how can I set that back???

caduel
10th December 2008, 12:42
What should the listview do with the icons?

If you really are using a QListView, you will need a "model" for it. Both the QListView (QAbstractItemView::setDragDropMode()) and the model (QAbstractItemModel::mimeTypes(), QAbstractItemModel::dropMimeData()) need to support DnD.
For details see: model-view-dnd

(You are aware the the rought equivalent of a Qt3 "list view" is a QTreeWidget?)

HTH

batileon
11th December 2008, 03:46
Actually I m using the Q3ListView

What I want to do is just like there is a tree with some nodes(which are some folder) or left side, and there are some icons on the right(IconView items), and can drag the icon to different nodes.

Actually the code works well in QT3, so I want to know is there anything I need to set in order to let the tree listview accept the icon drag.

caduel
11th December 2008, 11:00
have you set setAcceptDrops(true)?

batileon
12th December 2008, 01:41
Yes, I have set that
I think the problem now is that there's still a "no entry" icon shown when I drag the item to the ListView tree, which means even I have set setAcceptDrop(true), seems it still reject dropping....... >.<