[Interest] Changing link color of QLabel

Nikos Chantziaras realnc at gmail.com
Tue Mar 27 12:42:04 CEST 2012

On 27/03/12 11:45, André Somers wrote:
> Op 27-3-2012 9:32, Nikos Chantziaras schreef:
>> On 27/03/12 10:19, Nikos Chantziaras wrote:
>>> Links in QLabels do not obey their palette setting (QPalette::Link).
>>> How do I change the color of links?  An HTML style tag, like:
>>>       a {color: some_color;}
>>> doesn't help me, since what I need is set the link color to the same
>>> color as normal text, whatever that happens to be in the current
>>> desktop's color theme.
>>> Any solution to this problem?
>> A suboptimal way to do it is to get the wanted color and make a string
>> out of it with QColor::name().  The problem with this one is that the
>> color is still fixed.  If the desktop environment changes the palette
>> (user changed the color theme, for example), the color is not updated.
> So, how about you use QLabel::palette() to get the palette color, and
> then use that color in the style sheet?

This is what I described above.  Getting the color and then using its 
name().  But when the palette changes, the color doesn't get updated.

More information about the Interest mailing list