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

Qt Code:
  1. void f()
  2. {
  3. // ...
  4. page()->mainFrame()->evaluateJavaScript("invocation of js function is here");
  5. // ...
  6. }
To copy to clipboard, switch view to plain text mode 

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

Qt Code:
  1. void f2()
  2. {
  3. startTimer(1);
  4. }
To copy to clipboard, switch view to plain text mode 

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?