Qt-interest Archive, September 2007
How to alter QLabel link color?
Message 1 in thread
Using qt4.3.1:
It seems QLabel ignores settings for QPalette::Link and QPalette::LinkVisited.
The QLabel doc says:
Note that QLabel is well-suited to display small rich text documents, such as
small documents that get their document specific settings (font, text color,
link color) from the label's palette and font properties.
However in QPalette it says:
Note that we do not use the Link and LinkVisited roles when rendering rich
text in Qt, and that we recommend that you use CSS and the
QTextDocument::setDefaultStyleSheet() function to alter the appearance of
links.
Hmmm ... QLabel has no public QTextDocument ...
Any idea how to achieve this?
Frank
--
[ signature omitted ]
Message 2 in thread
Frank Hemer wrote:
> Using qt4.3.1:
>
> It seems QLabel ignores settings for QPalette::Link and QPalette::LinkVisited.
>
> The QLabel doc says:
> Note that QLabel is well-suited to display small rich text documents, such as
> small documents that get their document specific settings (font, text color,
> link color) from the label's palette and font properties.
>
> However in QPalette it says:
> Note that we do not use the Link and LinkVisited roles when rendering rich
> text in Qt, and that we recommend that you use CSS and the
> QTextDocument::setDefaultStyleSheet() function to alter the appearance of
> links.
>
> Hmmm ... QLabel has no public QTextDocument ...
>
Try embedding the style sheet in the html or using an inline style sheet.
<html><style>a { color: green; } a:visited { color: red; }</style><body>
<a href="foo.com">website</a> . click to do something</body></html>
Note that a:visited won't work since Qt does not track links that have
been visited and not visited.
Girish
--
[ signature omitted ]