You also need to reimplement dragEnterEvent()
and dropEvent()
- they are virtual functions in QListView
.
From the documentation:
Dropping
To be able to receive media dropped on a widget, call setAcceptDrops(true) for the widget, and reimplement the dragEnterEvent() and dropEvent() event handler functions.
For example, the following code enables drop events in the constructor of a QWidget subclass, making it possible to usefully implement drop event handlers:
void Window::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasFormat("text/plain"))
event->acceptProposedAction();
}
void Window::dropEvent(QDropEvent *event)
{
textBrowser->setPlainText(event->mimeData()->text());
mimeTypeCombo->clear();
mimeTypeCombo->addItems(event->mimeData()->formats());
event->acceptProposedAction();
}