Reading order after Drag & Drop in QSortFilterProxyModel
-
I have a QTableView that I would like to allow the user to sort alphabetically by column, and/or by dragging and dropping entire rows.
My problem is I do not know how to read the order of the rows as they are currently displayed by the view if the user has used drag and drop to reorder them.
So far I have a QTableView displaying a QSortFilterProxyModel with a source model of a QStandardItemModel. In my tableview I have set:
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->tableView->verticalHeader()->setSectionsMovable(true); mySortProxyModel->setDynamicSortFilter(true); ui->tableView->setSortingEnabled(true);
With this the user is able to sort by column and/or drag rows around.
When I loop through my proxymodeI I can get the order of the rows as if the user has only sorted by columns, but not if they have also moved rows around it has no affect.
How can I get the final order of rows as shown in the view, regardless of how the user sorted or drag and drop'd them in that order?