1)Qlineargradient
setStyleSheet("background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 rgba(255,0,0,255),stop:0.5 rgba(0,255,0,255),stop:1 rgba(0,0,255,255))");
参数说明:pad/repeat:扩充样式
(x1,y1):渐变起点,(x2,y2):渐变终点
渐变范围:[0,1],在[0,1]区间内可以任意设置颜色点
2)QRadialgradient
setStyleSheet("background:qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.3, fx:0.5, fy:1, stop:0 rgba(0, 0, 0, 255), stop:0.19397 rgba(0, 0, 0, 255), stop:0.202312 rgba(122, 97, 0, 255), stop:0.495514 rgba(76, 58, 0, 255), stop:0.504819 rgba(255, 255, 255, 255), stop:0.79 rgba(255, 255, 255, 255), stop:1 rgba(255, 158, 158, 255))")
参数说明:pad/repeat:扩充样式
(cx,cy):原点
radius:半径
(fx,fy):辐射方向
渐变范围:[0,1],在[0,1]区间内可以任意设置颜色点
3)QConicalgradient
setStyleSheet("background:qconicalgradient(cx:0.5, cy:0.5, angle:0, stop:0 rgba(35, 40, 3, 255), stop:0.16 rgba(136, 106, 22, 255), stop:0.225 rgba(166, 140, 41, 255), stop:0.285 rgba(204, 181, 74, 255), stop:0.345 rgba(235, 219, 102, 255), stop:0.415 rgba(245, 236, 112, 255), stop:0.52 rgba(209, 190, 76, 255), stop:0.57 rgba(187, 156, 51, 255), stop:0.635 rgba(168, 142, 42, 255), stop:0.695 rgba(202, 174, 68, 255), stop:0.75 rgba(218, 202, 86, 255), stop:0.815 rgba(208, 187, 73, 255), stop:0.88 rgba(187, 156, 51, 255), stop:0.935 rgba(137, 108, 26, 255), stop:1 rgba(35, 40, 3, 255))")
参数说明:(cx,cy):辐射原点
angle:辐射方向,水平向右为0度
渐变范围:[0,1],在[0,1]区间内可以任意设置颜色点