Hello,
I have problem with selection inside model/views (ListView and TableView). The problem is that I want to remove from QStandardItemModel selected rows, everything works fine, except that some selected items are not removed. I spend few days looking at the code/reading but couldn't find solution.

So I do this:
assign model and itemselectionmodel to views (for clarity sake i post only TableView code) like this:
Qt Code:
  1. tableView->setModel( &model ); //setup model before show()
  2. tableView->setSelectionBehavior( QAbstractItemView::SelectRows );
  3. smodelTable = new QItemSelectionModel( &model );
  4. tableView->setSelectionModel( smodelTable ); //I use atm. two separate selectionmodels only to figure out the problem
To copy to clipboard, switch view to plain text mode 
then, after item are selected, I use this code to remove selected rows from model:

Qt Code:
  1. void MainWindow::clearSelectedItemsSlot()
  2. {
  3. QModelIndexList selIndeModel;
  4.  
  5. if( listView->isVisible()){
  6. selIndeModel = smodelList->selectedIndexes(); //for listView
  7. }else{
  8. selIndeModel = smodelTable->selectedRows(); //for tableView
  9. }
  10.  
  11. for( int i = 0; i < selIndeModel.size(); ++i )
  12. {
  13. model.removeRow( selIndeModel[i].row() );
  14. fileNames.removeAt( selIndeModel[i].row() );
  15. }
  16.  
  17. selIndeModel.clear(); //for test purpose
  18. smodelList->clearSelection();
  19. smodelTable->clearSelection();
  20. }
To copy to clipboard, switch view to plain text mode 
Items are indeed removed, but sometimes one stays in model, sometimes one in middle, depending what was selected.
I can't think of any reason why this is happening.

Any suggestion are more then welcome.
PS> This behaviour is same for both listView and tableView, so I suspect that my remove code is wrong