Hello all,

I'm making my own model to work with a QTableView, by subclassing QAbstractTableModel.
The table will have to work with many rows.
Everything works well, except when I try to remove the selected rows in the table.

This is the removeRows of the model:

Qt Code:
  1. bool SubViewerModel::removeRows( int position, int rows/*,
  2. const QModelIndex& parent*/ )
  3. {
  4. beginRemoveRows( QModelIndex(), position,
  5. position + rows-1 );
  6.  
  7. for ( int row = 0; row < rows; ++row )
  8. subtitles->removeAt( position );
  9.  
  10. endRemoveRows();
  11.  
  12. return true;
  13. }
To copy to clipboard, switch view to plain text mode 

and this is how the function is called:

Qt Code:
  1. void MainWindow::deleteSelected()
  2. {
  3. QItemSelectionModel *selModel =
  4. subViewer->selectionModel();
  5.  
  6. QModelIndexList indexes =
  7. selModel->selectedRows();
  8.  
  9. foreach ( QModelIndex index, indexes )
  10. subViewerModel->removeRows( index.row(), 1 );
  11.  
  12. setWindowModified( true );
  13. }
To copy to clipboard, switch view to plain text mode 

If I select just one row, this row is deleted correctly, but I select various rows it will delete other rows that aren't selected.
Other problem is that deleting a great number of rows takes a long time...

Any sugestions to solve this?

Thanks!