解决方案是:使用合并
ui->tableWidget->setSpan(i,j,row_count,colcount);//合并ui->tableWidget->item(i,j)->setText(QString(""));ui->tableWidget->item(i,j)->setFlags(Qt::NoItemFlags);//反向操作ui->tableWidget->item(i,j)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled );ui->tableWidget->setSpan(i,j,1,1);