[Qt-qml] How to remove underlining of links in StyledText
Niels Mayer
nielsmayer at gmail.com
Tue Feb 21 07:48:05 CET 2012
On Thu, Feb 16, 2012 at 6:24 AM, <Mikko.Tuokko at nokia.com> wrote:
> how to remove automatic underlining of links marked with <a href=""></a> in QML Text using Text.StyledText ?
> I was able to change the font color of the link by adding extra <font color=""> tag inside the anchor definition but did not yet find a working way to remove the underlining.
> Appreciate any advice, I'm using Qt5...
A little code from http://voicetogoog.googlecode.com may provide some
hints on using a stylesheet to accomplish what you need.
Note that I used Text.RichText to accomplish this, not Text.StyledText
and this is for Qt 4.7.X... (ymnv).
// when TextEdit property textFormat==Text.RichText, such as
Component.ModalTextEdit in readOnly mode, any embedded links
// are difficult to see against dark background. Override the
defaults values, which appear to be
// QPalette::Link --> Qt::blue and QPalette::LinkVisited -->
Qt::magenta, per
http://doc.qt.nokia.com/latest/qpalette.html#ColorRole-enum
property string _RICHTEXT_STYLESHEET_PREAMBLE: "<html><style>a {
text-decoration: underline; color: '"
+ _ACTIVE_TEXT_COLOR
+ "' } </style><body>";
property string _RICHTEXT_STYLESHEET_APPENDIX: "</body></html>";
[...]
dialog.text = _RICHTEXT_STYLESHEET_PREAMBLE
+ "<strong>Ok to browse URL?</strong><br\><a href='"
+ url
+ "'>"
+ url
+ "</a>"
+ _RICHTEXT_STYLESHEET_APPENDIX;
-- Niels
http://nielsmayer.com
More information about the Qt-qml
mailing list