Most efficient line deletion strategy for QStandardItemModel
I have a QStandardItemModel with several 100,000 data records and a QSortFilterProxyModel on top of it for filtering and sorting. I want to delete a significant number of records, say 100,000, based on the value of one of the columns.
The current implementation iterates over the original model, checks the value in the appropriate column, and calls removeRow. This turns out to be an extremely slow approach, I don't know why (I have already disabled the signaling of the original model and sortfilterproxymodel).
What is a more efficient approach?
Can QSortFilterProxyModel help, eg. by creating a recordset to remove and using removeRows?
Thanks, Andreas
source to share
QAbstractItemModel::removeRows()
is a candidate, provided the strings are contiguous. If the model is sorted by the column you are using to perform the delete test, then you should be able to use that.
source to share