<?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[Not able to receive signal in more than one QML file]]></title><description><![CDATA[<p dir="auto">Hi all,<br />
I am new to Qt and QML. Signal emitted from cpp file is not received by two of my QML files. Though I am able to receive the signal in one QML but why it is not  received by another QML.I have used<br />
engine.rootContext()-&gt;setContextProperty("my module",&amp;myfile) in main.cpp and using connections in both qml file<br />
Connections{<br />
target: myfile<br />
function onSignal1() {<br />
}<br />
}<br />
It works in one file.</p>
<p dir="auto">Thanks in advance.</p>
]]></description><link>https://forum.qt.io/topic/145864/not-able-to-receive-signal-in-more-than-one-qml-file</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 08:57:30 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/145864.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Jun 2023 04:58:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Not able to receive signal in more than one QML file on Mon, 19 Jun 2023 05:38:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gery">@<bdi>Gery</bdi></a> from the point of view of the QML engine, your root context property already is a singleton (it is a single, global object, visible from all QML code).</p>
<p dir="auto">If your other QML file is not loaded when signal is emitted, you have 2 options I think:</p>
<ul>
<li>Load the file earlier (maybe with a Loader? It's really hard to say for me since I don't know your code)</li>
<li>make sure the data from signal is available in your <code>myModule</code> object later, when the other QML file needs it. For example, <code>myModule</code> can have a Q_PROPERTY which holds the data. Then QML can always access it easily</li>
</ul>
]]></description><link>https://forum.qt.io/post/761859</link><guid isPermaLink="true">https://forum.qt.io/post/761859</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Mon, 19 Jun 2023 05:38:28 GMT</pubDate></item><item><title><![CDATA[Reply to Not able to receive signal in more than one QML file on Mon, 19 Jun 2023 05:31:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sierdzio">@<bdi>sierdzio</bdi></a> sorry for typo, I have used myModule only and its working in one. Is there any work around to work with same live object, is it using singleton object, I am bit stuck on it.</p>
]]></description><link>https://forum.qt.io/post/761858</link><guid isPermaLink="true">https://forum.qt.io/post/761858</guid><dc:creator><![CDATA[Gery]]></dc:creator><pubDate>Mon, 19 Jun 2023 05:31:23 GMT</pubDate></item><item><title><![CDATA[Reply to Not able to receive signal in more than one QML file on Mon, 19 Jun 2023 05:28:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gery">@<bdi>Gery</bdi></a> said in <a href="/post/761850">Not able to receive signal in more than one QML file</a>:</p>
<p dir="auto">You register <code>my module</code> as object name, but you try to connect to <code>myfile</code>. That might be one part of the problem. Another (just a guess) is that when signal is sent, only one of the QML files is open and loaded by the engine. So the other one does not receive the signal because it's not a live object.</p>
<pre><code>engine.rootContext()-&gt;setContextProperty("my module",&amp;myfile) 

Connections{
  target: myfile
  function onSignal1() {
  }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/761857</link><guid isPermaLink="true">https://forum.qt.io/post/761857</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Mon, 19 Jun 2023 05:28:05 GMT</pubDate></item><item><title><![CDATA[Reply to Not able to receive signal in more than one QML file on Mon, 19 Jun 2023 05:13:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gery">@<bdi>Gery</bdi></a> how do you connect to your signal in both QML files?</p>
]]></description><link>https://forum.qt.io/post/761851</link><guid isPermaLink="true">https://forum.qt.io/post/761851</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Mon, 19 Jun 2023 05:13:31 GMT</pubDate></item></channel></rss>