Change icon color in style sheet?
-
Is there any way to change an SVG icons color via the qss style sheet? I know I can change the icon itself in the style sheet, but I'd like to just have a single black icon for each button and then apply a solid color to it for each style. If that's not possible I guess I'll have to create a custom icon for each style and state.
-
css can not modify an attribute of an image
-
Hi
SVG being XML you can create a copy and change its color so you generate the other versions "on the fly"
https://stackoverflow.com/questions/15123544/change-the-color-of-an-svg-in-qt
You can also make a custom Button widget that uses
QGraphicsColorizeEffect
to live draw the same icon with different colors for each state.To use your new button widget, you can use QtCreators promote feature to make it easy
to use the new button all over the forms where you currently have the standard button.