View Full Version : [ask] reload a QWebPage

17th June 2013, 13:14
Hi all,

I'm currently creating a widget program that construct html page using QWebView.
Workflow of the code probably like this.
1. Get HTML string from external site.
2. find all <img> tag from that page using QRegExp.
3. save all urls from img src and then replace it to local path (i.e. http://www.qtcentre.org/images/smilies/smile.png become /home/user/img/smile.png)
4. set QWebView html source using setHtml()
5. Download all images from saved urls and save it to local disk using QNetworkAccessManager.
6. If all images successfully downloaded, reload QWebView.

I managed to finish step 1-5, but I'm stuck at step 6.
I didn't use QWebPage settings attribute to auto load images because I want all the images saved to local disk.
I've tried webview->update(), webview->repaint(), webview->triggerPageAction(QWebPage::Reload, true) but there is no effect.
My local image will be shown only if I reset its html source again using setHtml().

Is there another way to reload my QWebView page so that my recently downloaded images will be shown directly with out resetting its html source?

thank you

19th June 2013, 01:34
I am assuming you tried the obvious QWebView::reload()... I suspect that does nothing because it has no URL to reload from (having been loaded directly).

Why do you need to void simply setting the same HTML again?