QtWebEngine - synchronously execute JavaScript to read function result
I have the following method in one of my C++ classes (using QtWebEngine): QString get() { QString result; view->page()->runJavaScript("test();", [this](const QVariant &v) { result = v.toString(); }); return result; } It is to execute test() JS function and return the result of this invocation. Unfortunately, the callback is asynchronous and the program crashes. How can I make it work? The callback is asynchronous because the JavaScript execution occurs not only in another thread but in another process . So there is no way to make it fully synchronous. The best possible solution would be to