PDA

View Full Version : QtWebKit and problem with events



piotr.dobrogost
29th September 2009, 12:36
Hi

I'm observing strange behavior of my program and would like to know what could be the reason for this.

I have a function, let's call it f which looks something like this


void f()
{
// ...
page()->mainFrame()->evaluateJavaScript("invocation of js function is here");
// ...
}

The call to evaluateJavaScript and subsequent evaluation of the js functions should cause WebKit to create and send a network request (QNetworkRequest). The problem is this does not happen. However introducing another function f2 which looks like this


void f2()
{
startTimer(1);
}

and placing a call to the original f function inside timerEvent method makes the code works; network request is created and sent as a result of a call to evaluateJavaScript.

I suspect it has something to do with the main (gui) event loop and the fact that QtWebKit "lives" in the gui thread and is unable to finish its work if program does not return control to the main event loop from time to time. I'm new to event driven programming and don't know how to find where the problem is exactly.

What could be the reason the first version of code does not work whereas the second version works?