listWidget->setAlternatingRowColors(true);
listwidget若需隔行改变行的颜色需加上此句话
QString css = R"(
QListView
{
background:#111111;
color:#338833;
alternate-background-color:#333333;
show-decoration-selected:0;
font-size:20px;
}
QListView::item
{
min-height:64px;
margin:1px;
}
QListView::item:selected
{
background:qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #112233,stop:1 #1122aa);
}
QListView::item::hover
{
color:#00ff00;
background:qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #334455,stop:1 #1122aa);
}
QListView::indicator
{
width: 48px;
height:48px;
}
QListView::indicator:unchecked
{
image:url();
}
QListView::indicator:checked
{
image:url();
}
Widget
{
background:qlineargradient(x1:0, y1:0, x2:1, y2:1,stop:0 #777777,stop:1 #111111);
}
QScrollBar
{
background:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 #555555,stop:1 #aaaaaa);
}
QScrollBar::handle
{
background:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 #888888,stop:1 #333333);
}
QScrollBar::add-page
{
background:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 #aaaaaa,stop:1 #555555);
}
QScrollBar::sub-page
{
background:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 #666666,stop:1 #999999);
}
)";