Drop into specific item of WidgetList
I got a WidgetList, which contains some items. Now I want to drag some items onto those items in the WidgetList, like when I drop music into an iTunes playlist. I know how to drop data into a WidgetList, but how do I determinate on which item I dropped the data? After that I will do some further processing.
Thanks for your help :D
If you are using a QListView then you can access the index of the item while dropping to the list based on event position. You need to subclass your QListView and override the following functions based on your requirement :-
@void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
void startDrag(Qt::DropActions supportedActions);@
In the dropEvent you can get the index using :-
@QModelIndex index = indexAt(event->pos());@
You can also set the mimeData inorder to differentiate between multiple lists.
I have worked on few cases with drag & drop on listView, if you need any help feel free to ask.