Qt5: Drag and Drop when using QSortFilterProxyModel

that has different Listviews that are filtered using a sub-classed QSortFilterProxyModel for each view. The data in the view can be sorted when the user clicks a sort button.

I implemented the drag and drop inside the QSortFilterProxyModel, to change the state of the data when it is dropped into a new Listview. This works fine, however, manually sorting the items within a listview causes all other listview displaying the same data to be sorted as well, which is not what I want.

Example, View 1 shows all participants, view 2 shows participants that are active. When dragged from view 1 to view 2, the participant becomes active. If I manually sort the participants, the index of participants that are active also get sorted. This does however not happen if I automatically sort them using

proxyModel->sort()

method.

How can I manually rearrange the data in the proxy model without changing the index in the source model?

Don't modify DataModel

The point of QSortFilterProxyModel is that you can provide a new ordering completely independently of any other view on the underlying data. Having that view move the underlying rows around breaks that.

You should instead write a proxy that provides the manual override of ordering, recording where each row should be positioned. This can use the QSortFilterProxyModel as its source, which in turn sources from DataModel