[Interest] Changing link color of QLabel

72 views
Skip to first unread message

Nikos Chantziaras

unread,
Mar 27, 2012, 3:19:39 AM3/27/12
to inte...@qt-project.org
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?

_______________________________________________
Interest mailing list
Inte...@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Nikos Chantziaras

unread,
Mar 27, 2012, 3:32:25 AM3/27/12
to inte...@qt-project.org
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.

André Somers

unread,
Mar 27, 2012, 4:45:16 AM3/27/12
to inte...@qt-project.org
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?

André

Nikos Chantziaras

unread,
Mar 27, 2012, 6:42:04 AM3/27/12
to inte...@qt-project.org
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.

André Somers

unread,
Mar 27, 2012, 8:00:43 AM3/27/12
to inte...@qt-project.org
Op 27-3-2012 12:42, Nikos Chantziaras schreef:

> 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.
>
Does that really happen in your application then?

André

Reply all
Reply to author
Forward
0 new messages