WebKit: mainFrame()->load(url) in a for loop
Hi,
i would like to download sequentially an unknown number of webpages. So I naturally thought of using a for loop to achieve that.
But the problem is that mainFrame()->load(url) doesn't wait if a previous load was already running for the same QWebPage object. As a consequence the previous download is interrupted and the signal loadFinished is emitted, but when the corresponding slot is executed it appears naturally that the content of the previous webpage is almost empty (at least the information I need is not available...).
At the end of the for loop, only the last download successfully achieves (probably because it is not interrupted...).
I could handle this using a global boolean :o, but I was wondering if there was a more elegant way to perform what I want using the Qt framework.
Any ideas ?
Re: WebKit: mainFrame()->load(url) in a for loop
http://doc.qt.nokia.com/4.6/qwebpage.html#loadFinished
Sorry, just reread your post and noticed that you mentioned the loadFinished signal.
Be sure to check out: http://doc.qt.nokia.com/4.6/qwebpage.html#loadProgress also. You could wait for the load while the loadProgress != 100
Re: WebKit: mainFrame()->load(url) in a for loop
I wouldn't post a thread if I didn't read the official documentation first.
Your answer doesn't help me at all...
Forget it I'll use my boolean idea.
Re: WebKit: mainFrame()->load(url) in a for loop
Well my boolean trick didn't work.
I had to use the loadFinished signal instead... not very intuitive...
Re: WebKit: mainFrame()->load(url) in a for loop
did you come up with a more elegant solution?
Re: WebKit: mainFrame()->load(url) in a for loop
Using loadFinished() is the proper solution. Of course if you really need WebKit and can't live with pure QNetworkAccessManager.
Re: WebKit: mainFrame()->load(url) in a for loop
usually yes, but for current project I use webkit to automate navigating deep into a javascript powered website, and the logic would be simpler if I could block while loading the HTML.
Is there a cleaner way to block than:
Code:
loaded = false; // set to true in loadFinished()
load(url);
while(!loaded) {
// wait
}
// process html
Re: WebKit: mainFrame()->load(url) in a for loop
Re: WebKit: mainFrame()->load(url) in a for loop