Okay, i tried Lykurg's code. But, there is build issues informed by Qt Creator.
O:/Qt/DeleteSelectedItemInListView/form.cpp:53: error: 'class QModelIndexList' has no member named 'sort'
Then, i looked at Qt Assistant, especially in QList Class Reference. There is no sort() function.
But, i found qSort() function when searching for keyword sort.
Then, I modified Lykurg's code like following.
ui->listView->setUpdatesEnabled(false);
QModelIndexList indexes = ui->listView->selectionModel()->selectedIndexes();
qSort(indexes.begin(), indexes.end());
for(int i = indexes.count() - 1; i > -1; --i)
model->removeRow(indexes.at(i).row());
ui->listView->setUpdatesEnabled(true);
ui->listView->setUpdatesEnabled(false);
QModelIndexList indexes = ui->listView->selectionModel()->selectedIndexes();
qSort(indexes.begin(), indexes.end());
for(int i = indexes.count() - 1; i > -1; --i)
model->removeRow(indexes.at(i).row());
ui->listView->setUpdatesEnabled(true);
To copy to clipboard, switch view to plain text mode
And that is work. Thanks for your sugesstion, wysota.
Bookmarks