Select to view content in your preferred language

How to change SVG Fill Color in QML

8367
2
07-03-2019 06:55 AM
LesVegetables
Emerging Contributor

How would one go about changing the fill color of an SVG image used in a tool button or elsewhere in QML? In all of the examples I've seen, an SVG asset is referenced as a value or an image source property, and I've not seen a property to change the fill color for the SVG. 

I suppose one could write some logic to open the SVG file, locate the fill color property (or properties in the case of a multi-path SVG) and change the color value but it seems like it should be a lot easier than that.

Tags (3)
0 Kudos
2 Replies
StephenQuan1
Esri Contributor

It really depends on your SVG. If there is an alpha channel defined (e.g. transparency), then, it may be sufficient to drop the SVG on top of something as plain as a colored Rectangle. If it's more sophisticated, then, I'd suggest you checkout ColorOverlay. https://doc.qt.io/qt-5/qml-qtgraphicaleffects-coloroverlay.html

LesVegetables
Emerging Contributor

That seems pretty janky

0 Kudos