设置 可 按 Ctrl 键 选中多行
ui.tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); // 整行选中,可按 Ctrl 键 选中多行
获取多个行的行索引
QModelIndexList indexList = ui.tableWidget->selectionModel()->selectedRows();
for (int i = 0; i < indexList.size(); i++)
{
// indexList.at(i).row(); 行索引,从 0 开始
}