<?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[Send text from Qt to QML]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I have no idea what might be wrong :/<br />
I am beginneer in Qt and QML. firstly I exchange data beetwen QML and Qt by Q_PROPERTY macro.</p>
<p dir="auto">Now I create next class to exchange data, and finnaly I have three registered object to exchange data  like below:<br />
main.cpp</p>
<pre><code>    qmlRegisterType&lt; PrinterSystemController &gt;("MyPrinterController",1,0,"PrinterSystemController");
    qmlRegisterType&lt; RfidSystemController    &gt;("MyRfidController",1,0,"RfidSystemController");
    qmlRegisterType&lt; NetworkSystemController &gt;("MyNetworkController",1,0,"NetworkSystemController");

</code></pre>
<p dir="auto">mian.qml</p>
<pre><code> PrinterSystemController {
        id: printerSystemController
    }

    RfidSystemController {
        id: rfidSystemController
    }

    NetworkSystemController {
        id: networkSystemController
    }
</code></pre>
<p dir="auto">In PrinterSystemController and RfidSystemController everythings works.  But in networSystemController  works only  Q_INVOKABLE metods calls form QML. When I try do some Q_PROPERTY :<br />
<code>  Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY userNameChanged)</code></p>
<p dir="auto">Next I set some QStirng value by:</p>
<pre><code>setUserName(userNameInput);
</code></pre>
<p dir="auto">and read this property in qml to text:</p>
<pre><code>   Text {
            text: networkSystemController.rfidnumber
            anchors.horizontalCenter: rectContuserTest.horizontalCenter
            anchors.verticalCenter: rectContuserTest.verticalCenter
            font.pixelSize: rectContuserTest.width * .15
            color: "white"
        }
</code></pre>
<p dir="auto">it doesn't work, without any warnings and erros.... what should I check ?</p>
]]></description><link>https://forum.qt.io/topic/141323/send-text-from-qt-to-qml</link><generator>RSS for Node</generator><lastBuildDate>Thu, 14 May 2026 12:16:38 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/141323.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Dec 2022 18:28:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Send text from Qt to QML on Sun, 11 Dec 2022 14:51:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a><br />
Yes, probably I found problem. QML create own object , and I created second object in Qt, so I worked from two different objects.</p>
<p dir="auto">I explain you .<br />
I have two class :<br />
<code>NetworkSystemController</code><br />
<code>NetworkProcessor</code><br />
The first class is to "data container" for QML visualisation, and them object is created by register this class in QML and import to QML.</p>
<pre><code>NetworkSystemController {
        id: networkSystemController
    }
</code></pre>
<p dir="auto">From my second class (<code>NetworkProcessor</code>) I would like to send <code>userDetails</code>  variable , so  I created object:</p>
<pre><code>NetworkSystemController * networkSystemController = new NetworkSystemController;
connect(this, &amp;NetworkProcessor::userDetails, networkSystemController,  &amp;NetworkSystemController::userDetails);
</code></pre>
<p dir="auto">and slot in <code>NetworkSystemController</code></p>
<pre><code>void NetworkSystemController::userDetails(QString userName)
{
    setUserName(userName);
}
</code></pre>
<p dir="auto">and <code>setUserName</code> metod :</p>
<pre><code>void NetworkSystemController::setUserName(const QString &amp;newUserName)
{
    if (m_userName == newUserName)
        return;
    m_userName = newUserName;
    emit userNameChanged();
     qDebug()&lt;&lt;"!!!here we are !!!";
}

</code></pre>
<p dir="auto">is always called, but <code>emit</code> signal not emitted to object created by QML, am I right ? I would be really gratefull if someone give me a tips how to realize my concept without creating <code>NetworkSystemController</code> object outsied QML ?</p>
]]></description><link>https://forum.qt.io/post/739847</link><guid isPermaLink="true">https://forum.qt.io/post/739847</guid><dc:creator><![CDATA[Damian7546]]></dc:creator><pubDate>Sun, 11 Dec 2022 14:51:09 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Fri, 09 Dec 2022 16:02:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/damian7546">@<bdi>Damian7546</bdi></a> qDebug()&lt;&lt;"!!!here we are !!!"; shows up in companyDetails() call?</p>
]]></description><link>https://forum.qt.io/post/739695</link><guid isPermaLink="true">https://forum.qt.io/post/739695</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Fri, 09 Dec 2022 16:02:09 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Fri, 09 Dec 2022 15:53:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> said in <a href="/post/739690">Send text from Qt to QML</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/damian7546">@<bdi>Damian7546</bdi></a> said in <a href="/post/739664">Send text from Qt to QML</a>:</p>
<blockquote>
<p dir="auto">void NetworkSystemController::companyDetails(QString userNamein)<br />
{<br />
setUserName(userNamein);<br />
}</p>
</blockquote>
<p dir="auto">change it here. You see the mismatch: QString userNamein and const QString &amp;newUserName<br />
void NetworkSystemController::companyDetails( const QString &amp; userNamein)<br />
{<br />
setUserName(userNamein);<br />
}</p>
</blockquote>
<p dir="auto">It isn't problem. I tested  function like:</p>
<pre><code>void NetworkSystemController::testFun(QString name)
{
    setUserName(QString);
}
</code></pre>
<p dir="auto">and works. but my still doesn't work :/</p>
<pre><code>void NetworkSystemController::companyDetails(QString userNamein)
{
    setUserName(userNamein);
}

</code></pre>
<p dir="auto">This two functions are only different call. First(good working) is called by button from visualisation, but <code>companyDetails</code> by emit signal from other object. ... And both functions are performed, but only first function <code>emit signal</code>  works properly with qml ...</p>
]]></description><link>https://forum.qt.io/post/739693</link><guid isPermaLink="true">https://forum.qt.io/post/739693</guid><dc:creator><![CDATA[Damian7546]]></dc:creator><pubDate>Fri, 09 Dec 2022 15:53:09 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Fri, 09 Dec 2022 15:31:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/damian7546">@<bdi>Damian7546</bdi></a> said in <a href="/post/739664">Send text from Qt to QML</a>:</p>
<blockquote>
<p dir="auto">void NetworkSystemController::companyDetails(QString userNamein)<br />
{<br />
setUserName(userNamein);<br />
}</p>
</blockquote>
<p dir="auto">change it here. You see the mismatch: QString userNamein and const QString &amp;newUserName<br />
void NetworkSystemController::companyDetails( const QString &amp; userNamein)<br />
{<br />
setUserName(userNamein);<br />
}</p>
]]></description><link>https://forum.qt.io/post/739690</link><guid isPermaLink="true">https://forum.qt.io/post/739690</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Fri, 09 Dec 2022 15:31:44 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Fri, 09 Dec 2022 10:06:14 GMT]]></title><description><![CDATA[<p dir="auto">I'm still struggling with mine problem, now I try called two functions like below:</p>
<pre><code>void NetworkSystemController::companyDetails(QString userNamein)
{
    setUserName(userNamein);
}
void NetworkSystemController::testFun()
{
    setUserName("testowyName");
}
</code></pre>
<p dir="auto">and <code>setUserName</code> definition:</p>
<pre><code>void NetworkSystemController::setUserName(const QString &amp;newUserName)
{
    if (m_userName == newUserName)
        return;
    m_userName = newUserName;
    emit userNameChanged();
     qDebug()&lt;&lt;"!!!here we are !!!";
}
</code></pre>
<p dir="auto">In both calling I get message "!!!here we are !!!" in console, but in QML signal works only by <code>testFun()</code> but doesn't work when called <code>companyDetails(QString userNamein)</code></p>
<p dir="auto">Any idea?</p>
]]></description><link>https://forum.qt.io/post/739664</link><guid isPermaLink="true">https://forum.qt.io/post/739664</guid><dc:creator><![CDATA[Damian7546]]></dc:creator><pubDate>Fri, 09 Dec 2022 10:06:14 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Thu, 08 Dec 2022 17:11:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> nothing....without logs after emit userNameChanged();</p>
<pre><code>      Connections {
            target: networkSystemController
            function onUserNameChanged() {
                console.log("===========")
            }
        }
        Text {

            text: networkSystemController.userName
            anchors.horizontalCenter: rectContuserName.horizontalCenter
            anchors.verticalCenter: rectContuserName.verticalCenter
            font.pixelSize: rectContuserName.width * .15
            color: "white"
        }
</code></pre>
<p dir="auto">What more can I check ?</p>
]]></description><link>https://forum.qt.io/post/739566</link><guid isPermaLink="true">https://forum.qt.io/post/739566</guid><dc:creator><![CDATA[Damian7546]]></dc:creator><pubDate>Thu, 08 Dec 2022 17:11:53 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Thu, 08 Dec 2022 16:51:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a>     add this in front of your Text to see what happens.</p>
<pre><code>Connections { 
        target: networkSystemController
        function onUserNameChanged() {
              console.log( "===========")
        }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/739565</link><guid isPermaLink="true">https://forum.qt.io/post/739565</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 08 Dec 2022 16:51:59 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Thu, 08 Dec 2022 16:39:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> Exactly:</p>
<pre><code>signals:
    void userNameChanged();
</code></pre>
]]></description><link>https://forum.qt.io/post/739560</link><guid isPermaLink="true">https://forum.qt.io/post/739560</guid><dc:creator><![CDATA[Damian7546]]></dc:creator><pubDate>Thu, 08 Dec 2022 16:39:55 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Thu, 08 Dec 2022 16:37:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/damian7546">@<bdi>Damian7546</bdi></a> did you define the signal  userNameChanged() in NetworkSystemController?</p>
]]></description><link>https://forum.qt.io/post/739559</link><guid isPermaLink="true">https://forum.qt.io/post/739559</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 08 Dec 2022 16:37:41 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Thu, 08 Dec 2022 16:35:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> I do that from beginning.</p>
<pre><code>void NetworkSystemController::setUserName(const QString &amp;newUserName)
{
    if (m_userName == newUserName)
        return;
    m_userName = newUserName;
    emit userNameChanged();
     qDebug()&lt;&lt;"!!!here we are !!!";
}
</code></pre>
<p dir="auto">And in console I got message "!!!here we are !!!",  and nothing in QML , so?</p>
]]></description><link>https://forum.qt.io/post/739557</link><guid isPermaLink="true">https://forum.qt.io/post/739557</guid><dc:creator><![CDATA[Damian7546]]></dc:creator><pubDate>Thu, 08 Dec 2022 16:35:11 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Thu, 08 Dec 2022 16:31:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/damian7546">@<bdi>Damian7546</bdi></a> "emit userNameChanged();" will update it.</p>
]]></description><link>https://forum.qt.io/post/739555</link><guid isPermaLink="true">https://forum.qt.io/post/739555</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 08 Dec 2022 16:31:17 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Thu, 08 Dec 2022 16:28:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a>  I noiced that now my qtCreator  in other way (propapbly after update) do <code>Generate Missing Q_PROPERTY Members</code></p>
<p dir="auto">Currently result :<br />
<img src="https://ddgobkiprc33d.cloudfront.net/c16a6a63-6941-40a1-a993-c687fd8568e2.jpg" alt="first.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">and before update it look like this:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/d40292af-91e8-48f0-a44d-6008611890ca.jpg" alt="second.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">I try rewrite my new Q_PROPERTY like old construction but still my  NetworSystemController  can't send QString to QML page. :/</p>
<p dir="auto">Any idea?</p>
]]></description><link>https://forum.qt.io/post/739554</link><guid isPermaLink="true">https://forum.qt.io/post/739554</guid><dc:creator><![CDATA[Damian7546]]></dc:creator><pubDate>Thu, 08 Dec 2022 16:28:41 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Wed, 07 Dec 2022 19:20:37 GMT]]></title><description><![CDATA[<p dir="auto">No, it is not a problem, when I did like below , the text appear on screen:</p>
<pre><code>Text {
            text: "Text test" ///networkSystemController.userName
            anchors.horizontalCenter: rectContuserName.horizontalCenter
            anchors.verticalCenter: rectContuserName.verticalCenter
            font.pixelSize: rectContuserName.width * .15
            color: "white"
        }
</code></pre>
]]></description><link>https://forum.qt.io/post/739392</link><guid isPermaLink="true">https://forum.qt.io/post/739392</guid><dc:creator><![CDATA[Damian7546]]></dc:creator><pubDate>Wed, 07 Dec 2022 19:20:37 GMT</pubDate></item><item><title><![CDATA[Reply to Send text from Qt to QML on Wed, 07 Dec 2022 18:35:03 GMT]]></title><description><![CDATA[<p dir="auto">copy and paste error?</p>
<pre><code>  Text {
            text: networkSystemController.userName
            anchors.horizontalCenter: rectContuserTest.horizontalCenter
            anchors.verticalCenter: rectContuserTest.verticalCenter
            font.pixelSize: rectContuserTest.width * .15
            color: "white"
        }
</code></pre>
]]></description><link>https://forum.qt.io/post/739386</link><guid isPermaLink="true">https://forum.qt.io/post/739386</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Wed, 07 Dec 2022 18:35:03 GMT</pubDate></item></channel></rss>