Hi all
I have a qt application in which I have a QTreewidget that displays some content in the QTextBrowser. I set the contents for the html document in the textbrowser using the setHtml() function. All I want now is to fetch the url of this html document so that I could use it later somewhere in my application. I looked around a lot but all in vain. I hope someone could help me with it.

Recommended Answers

All 3 Replies

  1. Show your code
  2. Can you tell us what you intend to do with the url link later? eg. download an image file etc...

According to the documentation, the setHtml() function sets the html data directly (as a QString containing the html code), and you can use toHtml() to retrieve that html code later on. If you got an html page from some URL and you dumped the html source code from that page into a QString that you passed to the setHtml() function, how could it ever be possible for the QTextBrowser object to have any idea of where that code came from?

What you need to use is the source property, which is used to get/set the URL of the page that you display in the QTextBrowser, as it is explained the documentation.

In summary, RTFM!

Hi Mike,
Thank you for the information.I did read the documentation before posting this thread. I did not get a proper solution to it so I posted this query.

In my case I have a huge QString that is passed to setHtml() to display the html document. I donot have any path or url using which I do the setSource(). So If I have to reference the links present in the html document from outside this will not be possible right?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.