I have a QSortFilterProxyModel, I need to select row for delete, so I am using a QPersistentModelIndex. QPersistentModelIndex is working well with multiple row selection, while other methods are not deleting all rows. My problem is, I can't mapToSource with the QPersistentModelIndex it needs QModelIndex. How can I overcome this?
model = QStandardItemModel()
filter = QSortFilterProxyModel()
self.filter.setSourceModel(model)
# Set the model/check function
table_view = QTableView()
table_view.setModel(filter)
# Delete Row using
index_list = []
for model_index in table_view.selectionModel().selectedRows():
index = QPersistentModelIndex(model_index)
index_list.append(index)
if index_list:
for index in index_list:
"The error is here, it only accepts `QModelIndex` and refuses `QPersistentModelIndex`"
ix = table_view.model().mapToSource(index.row())
# ix = table_view.model().mapToSource(index)
item = model.itemFromIndex(ix)