有没有办法在 PyQt 中将过渡颜色作为背景? 我尝试使用 CSS 的线性渐变,但不起作用
stylesheet = ("QWidget { background-color : linear-gradient(to right, red 50%, blue 50%);}")
如何让它为我工作?
最佳答案
我使用 x1, x2
而不是 to right
手动指定渐变的开始和停止坐标,并添加了 stop
关键字。
stylesheet = "QWidget {background-color: qlineargradient(x1: 0, x2: 1, stop: 0 red, stop: 1 blue)}"
或者您想要这样的急剧转变吗?
stylesheet = "QWidget {background-color: qlineargradient(x1:0, x2:1, stop: 0.49 red, stop: 0.51 blue)}"
关于python - 背景中的多种颜色(过渡),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64835508/