PDA

View Full Version : What design fits my situation?



caelestis
2nd February 2010, 02:57
I have a webview widget and I want to perform actions in a linear style to a web page. The problem is that I can't return to the code after I finish loading a url in the view, so how would I go back and finish executing everything? (C++)

Pseudo-code:


perform some tasks
webview loads a url
do stuff to page
webview loads another url
do stuff again


The loading happens concurrently, so for example the page will start loading and then it will already try to manipulate it and then load another page.

Coises
2nd February 2010, 04:20
I


perform some tasks
webview loads a url
do stuff to page
webview loads another url
do stuff again


Start an event loop.
Send a signal to slot firstStep.

In slot firstStep:
Perform some tasks.
Connect signal QWebView::loadFinished to slot secondStep.
Call QWebView::load.
return;

In slot secondStep:
Do stuff to page.
Connect signal QWebView::loadFinished to slot thirdStep.
Call QWebView::load.
return;

In slot thirdStep:
Do stuff again.
return.