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

+2


source to share


2 answers


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.



+1


source


A more efficient approach would be to implement your own model with a QAbstractItemModel interface instead of using QStandardItemModel. You can then create custom indexes to help you improve performance when deleting items.



+1


source







All Articles