<?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[QJSEngine, how to access and change class members]]></title><description><![CDATA[<p dir="auto">Hi, I am trying to write a simple scripting widget, where user can change variables of a qt class.<br />
I did the following to expose a qt class to JS:</p>
<pre><code>QJSEngine engine;
QJSValue objectValue = engine.newQObject(this-&gt;mThread);
engine.globalObject().setProperty("myObject", objectValue);
</code></pre>
<p dir="auto">my problem is that this:</p>
<pre><code>qDebug() &lt;&lt; "Number is:" &lt;&lt; engine.evaluate("myObject.tess_ ").toNumber();
</code></pre>
<p dir="auto">gives nan. even though variable tess_  has been initiated in my mThread class constructor.</p>
<p dir="auto">Also, by setting</p>
<pre><code>engine.evaluate("myObject.tess_ = 5 ") ;
</code></pre>
<p dir="auto">the value of class does not seem to change by calling:</p>
<pre><code>qDebug() &lt;&lt; this-&gt;mThread-&gt;tess_ ;
</code></pre>
<p dir="auto">I appreciate any help. also on how to make changes interactive, as one would expect in similar situations..</p>
]]></description><link>https://forum.qt.io/topic/139558/qjsengine-how-to-access-and-change-class-members</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 13:08:11 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139558.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Sep 2022 13:18:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QJSEngine, how to access and change class members on Wed, 28 Sep 2022 16:48:02 GMT]]></title><description><![CDATA[<p dir="auto">bringing this up, any suggestion? interesting is that when I evaluate a function, the class members get updated. but if I directly change a member with evaluate, it is not changed in c++ code!!</p>
]]></description><link>https://forum.qt.io/post/730574</link><guid isPermaLink="true">https://forum.qt.io/post/730574</guid><dc:creator><![CDATA[mhsgoud]]></dc:creator><pubDate>Wed, 28 Sep 2022 16:48:02 GMT</pubDate></item></channel></rss>