My code im using
QModelIndexList indexes = ui->tableUserVars->selectionModel()->selectedRows();
int countRow = indexes.count();
for( int i = countRow; i > 0; i--)
modelUserVars
->removeRow
( indexes.
at(i
-1).
row(),
QModelIndex());
QModelIndexList indexes = ui->tableUserVars->selectionModel()->selectedRows();
int countRow = indexes.count();
for( int i = countRow; i > 0; i--)
modelUserVars->removeRow( indexes.at(i-1).row(), QModelIndex());
To copy to clipboard, switch view to plain text mode
And if you are working with a large number of rows ( > 100,000 ) and the selection of lines in order not to sample the rapid removal of this way + if the selection is selectively remove the row from selectionModel
My code im using fast delete rows > 1000000
QModelIndexList indexes = ui->tableUserVars->selectionModel()->selectedRows();
int countRow = indexes.count();
bool flagDif = false;
for( int i = countRow; i > 1; i--)
if (indexes.at(i-1).row()-1 != indexes.at(i-2).row())
flagDif = true;
if (!flagDif)
modelUserVars
->removeRows
(indexes.
at(0).
row(),countRow,
QModelIndex());
else
for( int i = countRow; i > 0; i--)
modelUserVars
->removeRow
( indexes.
at(i
-1).
row(),
QModelIndex());
QModelIndexList indexes = ui->tableUserVars->selectionModel()->selectedRows();
int countRow = indexes.count();
bool flagDif = false;
for( int i = countRow; i > 1; i--)
if (indexes.at(i-1).row()-1 != indexes.at(i-2).row())
flagDif = true;
if (!flagDif)
modelUserVars->removeRows(indexes.at(0).row(),countRow,QModelIndex());
else
for( int i = countRow; i > 0; i--)
modelUserVars->removeRow( indexes.at(i-1).row(), QModelIndex());
To copy to clipboard, switch view to plain text mode
Ps. Sorry bad englsh.
Bookmarks