首先设置:
setAlternatingRowColors(true);
setAlternatingRowColor方法,即具有alternatingRowColors属性。要使隔行颜色交替显示起作用,必须把该属性设置为true;
样式表background-color属性设置背景色,如果没有设置该值,则默认以QPalette::Base颜色显示
交替色:alternate-background-color:rgb(217,225,240);
背景色:background-color:rgb(255,255,255)");
ui->tableView->setAlternatingRowColors(true);
ui->tableView->setStyleSheet("alternate-background-color:rgb(217,225,240);
background-color:rgb(255,255,255)");
显示效果: