I had the same problem lately, and found maps very convenient for the job:
void ALocalvalueTableView::removeSelected()
{
QMap<int, int> rows;
rows.insert(index.row(), 0);
QMapIterator<int, int> r(rows);
r.toBack();
while (r.hasPrevious()) {
r.previous();
model()->removeRow(r.key());
} // while
} // removeSelected
void ALocalvalueTableView::removeSelected()
{
QMap<int, int> rows;
foreach (QModelIndex index, selectedIndexes())
rows.insert(index.row(), 0);
QMapIterator<int, int> r(rows);
r.toBack();
while (r.hasPrevious()) {
r.previous();
model()->removeRow(r.key());
} // while
} // removeSelected
To copy to clipboard, switch view to plain text mode
Bookmarks