I have a QStandardItemModel with 10000 Rows. If I want to remove a huge percent of these like 5000 the performance is very bad and the gui freezes. I could run the remove in a thread, but I am concerned what could happend if a user clicks a row that is going to be removed shortly.

Qt Code:
  1. QModelIndexList indexes = ui->playTableView->selectionModel()->selectedRows();
  2.  
  3. for (int i=0; i<indexes.count(); i++) {
  4. if (!ui->playTableView->isRowHidden(indexes[i].row()) ) {
  5. plmodel->removeRow(indexes[i].row());
  6. }
  7. }
To copy to clipboard, switch view to plain text mode 

This works, but takes very long time; maybe 30 seconds. it gives a bad user experience. Is there a faster way?

any ideas?