PDA

View Full Version : How to use QWebView asynchronous call js function?



tiaoweiliao
23rd February 2018, 09:53
hi ,all.

i use evaluateJavaScript , but i find that is so slow.

i hope like QWebEngineView runJavaScript , asynchronous call.

How do you give me a hint?

thanks.

wysota
25th February 2018, 08:39
Bear in mind that QWebEngineView also has a single thread for the JavaScript world so the amount of time it takes to execute your script is similar, only that it doesn't block the UI. If you are only about asynchronousness, you can spawn a Worker in JS and make it execute your code.

tiaoweiliao
26th February 2018, 04:04
Thank you for your help.

i use QWebView , when call evaluateJavaScript , UI is blocked.

how to solve this problem.

Same problem with me. This issue appears to be unresolved. https://forum.qt.io/topic/12974/evaluatejavascript-only-works-in-the-main-thread/3

my code:

QTime time;
time.start();
QString method = QString(QString("add_html('%1')").arg(qsContent));
this->page()->mainFrame()->evaluateJavaScript(method);
qDebug()<<"time is : "<<time.elapsed();//1205ms