I have a qlistview on a qsqltablemodel. I want to reorder the rows in the table model by dragging them, i.e. internal drag & drop.

I thought I'd implement the sorting in the sql table in list-style, i.e. each row has a "previous_row" field. I'd do the sorting by putting a custom QSortFilterProxyModel on top of the QSqlTableModel.

Okay, well the problem is somewhere else:

I set up the QListView appropriately. When I use a QStandardItemModel on the QListView, drag & drop sorting works just fine! When I use a QSqlTableModel, it does weird things, which results in the dragged row to be deleted.

I don't know which function in the model handles the drop action on internal drag & drop. I tried overwriting QListView::dropEvent, but that's not the one that deletes my qsqltablemodel records.

I tried overwriting mimeTypes(), mimeData() and dropMimeData() in my proxy model, but dropMimeData() isn't even called when dropping a row (at least on internal drag & drop).

What function do I have to overwrite to implement my custom behaviour?

Thanks in advance,
Thomas