Reputation: 143
Is there a way to have transitioning colors as background in PyQt? I tried using CSS's linear-gradient, which doesn't work
stylesheet = ("QWidget { background-color : linear-gradient(to right, red 50%, blue 50%);}")
How do I get it to work for me?
Upvotes: 2
Views: 2910
Reputation: 4649
I manually specified the start and stop coordinates of the gradient using x1, x2
instead of to right
and added the stop
keywords.
stylesheet = "QWidget {background-color: qlineargradient(x1: 0, x2: 1, stop: 0 red, stop: 1 blue)}"
Or did you want a sharp transition like this?
stylesheet = "QWidget {background-color: qlineargradient(x1:0, x2:1, stop: 0.49 red, stop: 0.51 blue)}"
Upvotes: 5