这个感觉挺简单的实现起来。 connect(ui->tableWidget,SIGNAL(cellEntered(int,int)),this,SLOT(hover(int,int)));void fileDisplay::hover(int a, int b) { for(int i=0; i < 8;i++){ if(i != a){ ui->tableWidget->item(i,0)->setBackgroundColor(QColor(66, 93, 185, 255)); ui->tableWidget->item(i,1)->setBackgroundColor(QColor(66, 93, 185, 255)); } } ui->tableWidget->item(a,0)->setBackgroundColor(QColor(131, 152, 213, 255)); ui->tableWidget->item(a,1)->setBackgroundColor(QColor(131, 152, 213, 255)); }