<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to get result from javascript code run by runJavaScript in QtWebengine?]]></title><description><![CDATA[<p dir="auto">How can I get the result from javascript run by runJavaScript in QtWebengine?</p>
<p dir="auto">I want to get result from the js run by runJavaScript. The result is formed after some time in js, but since js returns immediately, I can not get the mature result. How can I modify the js code or the C++ code to get the mature result? I know I can use QWebChannel to notify C++ of the mature result at appropriate time but that is a little complex. Can I delay the return time of js code so it can return with the matured result?</p>
<p dir="auto">C++:</p>
<pre><code>page()-&gt;runJavaScript(js,[this](const QVariant &amp;v) {
        qDebug()&lt;&lt;v.toString();
}
</code></pre>
<p dir="auto">js:</p>
<pre><code>var result="immature result";
function fun()
{
    result="mature result";
}
setTimeout(fun,2000);
result;
</code></pre>
]]></description><link>https://forum.qt.io/topic/105192/how-to-get-result-from-javascript-code-run-by-runjavascript-in-qtwebengine</link><generator>RSS for Node</generator><lastBuildDate>Wed, 20 May 2026 00:35:58 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/105192.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 21 Jul 2019 09:20:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to get result from javascript code run by runJavaScript in QtWebengine? on Wed, 04 Sep 2019 06:18:56 GMT]]></title><description><![CDATA[<p dir="auto">In your runJavascript function either you emit a signal or you can call a function of the save class and then pass the value in that function.</p>
<p dir="auto">page()-&gt;runJavaScript(js,[this](const QVariant &amp;v) {<br />
newFunction(v);<br />
}</p>
<p dir="auto">Then in newFunction you can carry out the further code.</p>
]]></description><link>https://forum.qt.io/post/549359</link><guid isPermaLink="true">https://forum.qt.io/post/549359</guid><dc:creator><![CDATA[Hetal]]></dc:creator><pubDate>Wed, 04 Sep 2019 06:18:56 GMT</pubDate></item><item><title><![CDATA[Reply to How to get result from javascript code run by runJavaScript in QtWebengine? on Mon, 22 Jul 2019 11:36:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yetanotherqtfan">@<bdi>yetanotherqtfan</bdi></a> <a href="https://doc.qt.io/qt-5/qwebenginepage.html#runJavaScript-2" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qwebenginepage.html#runJavaScript-2</a></p>
]]></description><link>https://forum.qt.io/post/542160</link><guid isPermaLink="true">https://forum.qt.io/post/542160</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 22 Jul 2019 11:36:33 GMT</pubDate></item></channel></rss>