[Interest] Force QPainter color draw for SVG files?

Stephen Chu stephen at ju-ju.com
Tue Apr 17 15:21:59 CEST 2012


If the SVG contains only solid black color, you can render it to a 
QBitmap first. Then draw the bitmap onto a color QPixmap or QImage with 
desired color as pen color and transparent background mode.

On 4/17/2012 3:20 AM, jaume dominguez faus wrote:
> Yes, I will try this. Thank you very much.
>
> On 04/16/2012 12:57 AM, wargand at gmx.de wrote:
>> SVG is xml. Just load it into a QDomDocument and change the colour.
>> If the SVG does not change too much, you could even do a search and
>> replace of the color values. There are many ways to achieve what you
>> want, forcing the QPainter to use a certain colour when rendering a SVG
>> image... I am not so sure about that.
>>
>> Btw... SVG isn't the most resource friendly format.
>>
>> Guido
>>
>>
>> On Sun, Apr 15, 2012 at 02:45:37PM +0200, jaume dominguez faus wrote:
>>
>>> Hi list.
>>>
>>> I guess the answer is "No". But maybe.... is it possible to force
>>> QPainter to paint only in, say "red", when I'm rendering a SVG
>>> that is black?  Imagine that you have a set of symbols in SVG
>>> files similar to a font characters, and you want to paint them in
>>> different colors when they are selected. Is it possible to do it
>>> without making the "selected version" of each SVG file?
>>>



More information about the Interest mailing list