QML Text element hyperlink

Gerharddc picture Gerharddc · Sep 21, 2012 · Viewed 10.2k times · Source

In my QML Text element I want to have a hyperlink to a website and managed to do so with it looking like one etc. but when I click or touch it nothing happens, the link is supposed to open in a the default browser.

Text {
    id: link_Text
    text: '<html><style type="text/css"></style><a href="http://google.com">google</a></html>'
}

Any idea what I'm doing wrong?

Answer

Gerharddc picture Gerharddc · Sep 21, 2012

Ok I just found that I have to add this:

onLinkActivated: Qt.openUrlExternally(link)

I did not originally consider something like this because I thought if the string was correctly formatted it would open the link on its own.