Reputation: 1367
I have custom QTableView
class that shows content of custom model based on QAbstractItemModel
. In the model I've implemented all needed methods to support changing rows order by DragAndDrop ( using dropMimeData()
).
But I do not know how to update selection in the view after model (and view) changed.
For example:
user clicks on the row, it becomes 'selected';
user drags this row to other place;
rows are swaps in the model and view;
BUT selection stays on the first selected row.
How model can notify view to change selection?
NOTE: I cant to create additional signals and slots because don't use MOC.
Upvotes: 0
Views: 762
Reputation: 1367
The solution is:
dropMimeData()
need to use beginMoveRows()
and andMoveRows()
around place where data changed.QAbstractItemModel::rowsMoved
of the model, where we can retrieve index of the target row.Upvotes: 0