/ /_tableModel是QStandardItemModel类,
QMessageBox::StandardButton reply = QMessageBox::question(NULL, "Delete", "Are you sure delete records?", QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::No)
return ;
QItemSelectionModel *selections = ui.tableView->selectionModel();
QModelIndexList selected = selections->selectedIndexes();
QMap<int, int> rowMap;
foreach(QModelIndex index, selected)
{
rowMap.insert(index.row(), 0);
}
int rowToDel;
QMapIterator<int, int> rowMapIterator(rowMap);
rowMapIterator.toBack();
while (rowMapIterator.hasPrevious())
{
rowMapIterator.previous();
rowToDel = rowMapIterator.key();
_tableModel->removeRow(rowToDel);
}
对qtableview 一些基本操作:连接
https://blog.youkuaiyun.com/a724699769/article/details/54407812