QTableWidget * tw = ui->tableWidget;// 保存要移动的行的数据QList<QTableWidgetItem *> items;for(int i = 0; i < 2; ++i){QTableWidgetItem * C0Item;QTableWidgetItem * C1Item;QTableWidgetItem * C2Item;int removeRow = -1;for(int row = 0; row < tw->rowCount(); ++row){if(tw->item(row, 1)->text() == "10" && !items.contains(tw->item(row, 2))){C0Item = tw->item(row, 0);tw->takeItem(row, 0);C1Item = tw->item(row, 1);tw->takeItem(row, 1);C2Item = tw->item(row, 2);tw->takeItem(row, 2);removeRow = row;items << C2Item;break;}}if(removeRow == -1){continue;}// 在第一行插入数据tw->insertRow(0);// 设置itemtw->setItem(0, 0, C0Item);tw->setItem(0, 1, C1Item);tw->setItem(0, 2, C2Item);qDebug() << "TaskManagerDialog::_sort_indicator_changed - item:" << C2Item->text()<< " item row:" << tw->row(C2Item)<< " removeRow + 1:" << removeRow + 1;// 删除原有的行tw->removeRow(removeRow + 1);}