[Qt-qml] How to remove underlining of links in StyledText

536 views
Skip to first unread message

Mikko....@nokia.com

unread,
Feb 16, 2012, 9:24:19 AM2/16/12
to qt-...@qt.nokia.com
Hi,

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...

BR,
Mikko
_______________________________________________
Qt-qml mailing list
Qt-...@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Niels Mayer

unread,
Feb 21, 2012, 1:48:05 AM2/21/12
to Mikko....@nokia.com, qt-...@qt.nokia.com
On Thu, Feb 16, 2012 at 6:24 AM, <Mikko....@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

Reply all
Reply to author
Forward
0 new messages