设置
QTableWidget *tb = ui->tableWidget; tb->setSelectionBehavior(QAbstractItemView::SelectRows); tb->setSelectionMode(QAbstractItemView::SingleSelection);操作
QTableWidget *tb = ui->tableWidget; int curRow=tb->currentRow(); //当前行号 tb->removeRow(curRow); //删除当前行及其items 可以选择中多行,点击按钮后,删除多行设置
QTableWidget *tb = ui->tableWidget; tb->setSelectionBehavior(QAbstractItemView::SelectRows); tb->setSelectionMode(QAbstractItemView::ExtendedSelection);操作
QTableWidget *tb = ui->tableWidget; QItemSelectionModel *m_selection = tb->selectionModel(); QModelIndexList indexList = m_selection->selectedIndexes(); QList list; int prev =-1,curr=-1; if(indexList.length()>1){//预处理第一行 prev = indexList.at(0).row(); list.append(prev); for(int i=1;i