user63898
user63898

Reputation: 30895

QTextBrowser set link, can't make it clickable

I'm using QTextBrowser, and setting it with link like this:

 QString url = 
    "http://developer.qt.nokia.com/doc/qt-4.8/qtextbrowser.html#source-prop";
 textBrowser->setOpenExternalLinks(true);
 textBrowser->setHTML(url);

or with:

 textBrowser->setSource(QUrl(url));

or even:

 QString u = "<a href=\""+url+"\">"+url+"</a>";
 textBrowser->setHTML(u);

but nothing happens. If I add the setSource I don't even see the fonts.

Upvotes: 3

Views: 1964

Answers (1)

shadyabhi
shadyabhi

Reputation: 17234

You have used

textBrowser->setHTML(url);

but it isn't actually a valid HTML to create a link. You need to use a href. See the supported html subset here.

https://doc.qt.io/archives/qt-4.8/richtext-html-subset.html

Upvotes: 1

Related Questions