0

When I run QWebFrame::evaluateJavaScript(scriptSource) from main thread everything seems to work just fine. But when I try to run it from a different thread I get a SyntaxError: Parse error. Even when I'm trying to run trivial code like 1+1;.

Can somebody explain why this occurs and whether this is the expected behavior?

Is there a possibility to use the QWebKit in another thread then the main thread?

P.S.: I am running Qt4.8

Senči
  • 911
  • 2
  • 10
  • 25

1 Answers1

0

I don't know much about QWebFrame or QT, but following should hold true.

In simplest terms, its GUI application and all the actions have to be done in main thread. If you have multiple threads, you will have to find a way to channel the call to main gui loop thread or main thread in your case.

One of the main reason is thread local storage that application could be using internally. If you execute the function from another thread local storage may not be set.

For GTK calls, most (all?) of the webkit calls have to be channelled through gtk idle hook so that it will get executed in proper thread. There should be something equivalent in QT.

user871199
  • 1,420
  • 19
  • 28