I want to delete multiple rows from QTableView and i have the code below.

Qt Code:
  1. QItemSelection selection( ui.tableView->selectionModel()->selection() );
  2. QList<int> rows;
  3. foreach( const QModelIndex & index, selection.indexes() ) {
  4. rows.append( index.row() );
  5. }
  6.  
  7. qSort( rows );
  8.  
  9. int prev = -1;
  10. for( int i = rows.count() - 1; i >= 0; i -= 1 ) {
  11. int current = rows[i];
  12. if( current != prev ) {
  13. tableModel->removeRows( current, 1 );
  14. prev = current;
  15. }
  16. }
  17.  
  18. QString sqlQuery = QString("DELETE FROM %1 WHERE id IN ('rows')").arg(tableName);
  19. //.arg( 1, 2, 3 ). or .arg( x ).arg( y ).arg( z )
  20. query.prepare(sqlQuery);
  21. query.exec();
To copy to clipboard, switch view to plain text mode 
How will write the 'rows' part?.