1.qss:
1
|
background-color
: qlineargradient(spread:
repeat
, x
1:
0
, y
1:
0
, x
2:
0
, y
2:
1
,
stop
:
0
#2ba0d6
,
stop
:
1
#138abd
);
|
2.widget:
1
2
3
4
5
6
7
8
|
QLinearGradient linearGradient(0, 0, 0, 300);
linearGradient.setColorAt(0.0, Qt::green);
linearGradient.setColorAt(1.0, Qt::blue);
QPalette pal;
pal.setBrush(QPalette::Window, QBrush(linearGradient));
//设置背景自动填充
ui->widget->setAutoFillBackground(
true
);
ui->widget->setPalette(pal);
|