簡述
QSS目前支持三種漸變填充:
- qlineargradient (線性漸變)
- qconicalgradient(圓錐漸變)
- qradialgradient(輻射漸變)
效果如下
qlineargradient
QPushButton {
background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
stop:0 white, stop: 0.4 gray, stop:1 green)
}
整個線性漸變軸長度爲1。
漸變位置:在這個例子中,(x1,y1)是起點,在左上角,(x2,y2)是終點在右下角。
漸變點設置:在0處設白色,在0.4處設灰色,在1處設綠色。
qconicalgradient
QPushButton {
background: qconicalgradient(cx:0.5, cy:0.5, angle:30,
stop:0 white, stop:1 #00FF00)
}
漸變位置:(cx,cy)是圓錐的中心,angle是漸變的起始角度
漸變點設置:在0處設白色,在1處設#00FF00
qradialgradient
QPushButton {
background: qradialgradient(cx:0, cy:0, radius: 1,
fx:0.5, fy:0.5, stop:0 white, stop:1 green)
}
漸變位置:(cx,cy)是圓的中心,radius圓的半徑,(fx,fy)是漸變的起始點
漸變點設置:在0處設白色,在1處設green
注:一定要自己嘗試一下
reference |