Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QtWebkit synchronous loading

Tags:

c++

qt

qtwebkit

I'm using a QWebPage without a QWebView because I want to render the contents of an HTML file onto a QPixmap/QImage.

I want the loading of the page to be done synchronously, not asynchronously which is the default. The default way is to call QWebFrame::setHtml() or QWebFrame::setContent(), but this loads images asynchronously. What I want is some sort of blocking function call, something like QWebFrame::waitUntilLoadFinished() after which I could just call render() and be done with it.

I can't find a way to do this. Am I missing something?

like image 772
Lucas Avatar asked Feb 05 '10 14:02

Lucas


1 Answers

If someone still needs it, this is how I got it working.

mWebPage->mainFrame()->setHtml("...");
QEventLoop loop;
connect(mWebPage,SIGNAL(loadFinished(bool)),&loop,SLOT(quit()));
loop.exec();
/* your webpage has finished loading & is ready to use */
like image 50
Jaydeep Solanki Avatar answered Oct 14 '22 19:10

Jaydeep Solanki