<?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[logmessage from another thread to the mainwindow slot]]></title><description><![CDATA[<p dir="auto">i have two classes that im trying to log a message to a textbrowser</p>
<ol>
<li>The main thread works</li>
<li>But if i call the  slot and try to emit the singal it does work.</li>
<li>is there a way to debug it</li>
</ol>
<pre><code>MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MainWindow)
    , m_window2(new Editor(this))
, m_window3(new T_Editor(this))
{
    ui-&gt;setupUi(this);
    connect(m_window2, &amp; Editor::logMessage, this, &amp;MainWindow::logMessage);
// new thread editor 
connect(m_window3, &amp; T_Editor::logMessage, this, &amp;MainWindow::logMessage);
}
</code></pre>
<p dir="auto">If i try to emit logmessage from the other thread it doesnt work. But if i emit from editor class it works. (both in the same thread)</p>
]]></description><link>https://forum.qt.io/topic/102253/logmessage-from-another-thread-to-the-mainwindow-slot</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 14:37:52 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/102253.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Apr 2019 13:03:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to logmessage from another thread to the mainwindow slot on Mon, 29 Apr 2019 19:09:48 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">If you want to log from different threads. You should rather have a dedicated object for that with proper protections in place.</p>
]]></description><link>https://forum.qt.io/post/525988</link><guid isPermaLink="true">https://forum.qt.io/post/525988</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 29 Apr 2019 19:09:48 GMT</pubDate></item><item><title><![CDATA[Reply to logmessage from another thread to the mainwindow slot on Mon, 29 Apr 2019 18:49:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sunfluxgames">@<bdi>Sunfluxgames</bdi></a> said in <a href="/post/525928">logmessage from another thread to the mainwindow slot</a>:</p>
<blockquote>
<p dir="auto">m_window3(new T_Editor(this))</p>
</blockquote>
<p dir="auto">I don't think this object (m_window3) lives in another thread at all...</p>
]]></description><link>https://forum.qt.io/post/525981</link><guid isPermaLink="true">https://forum.qt.io/post/525981</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Mon, 29 Apr 2019 18:49:54 GMT</pubDate></item><item><title><![CDATA[Reply to logmessage from another thread to the mainwindow slot on Mon, 29 Apr 2019 14:30:49 GMT]]></title><description><![CDATA[<p dir="auto">m_window3 to another thread after calling connect()? In that case, it may not work.</p>
<p dir="auto">belive this is what it is.</p>
<p dir="auto">mainwindow logMessage is a private member but guess i will have to make it public to access it from the other thread object</p>
<p dir="auto">create a connect in the T_editor class that connects the signal logmessage with slot of mainwindow slot.</p>
<p dir="auto">Editor/mainwindow both run on the same thread<br />
Editor create a thread for T_editor that creates its own object etc..</p>
]]></description><link>https://forum.qt.io/post/525938</link><guid isPermaLink="true">https://forum.qt.io/post/525938</guid><dc:creator><![CDATA[Sunfluxgames]]></dc:creator><pubDate>Mon, 29 Apr 2019 14:30:49 GMT</pubDate></item><item><title><![CDATA[Reply to logmessage from another thread to the mainwindow slot on Mon, 29 Apr 2019 13:12:50 GMT]]></title><description><![CDATA[<p dir="auto">In Qt, whether signal-slot connection crosses a thread boundary or not does not matter - it works same regardless of threads. The only thing which might not work is when custom objects are sent - but then all that is needed is to properly register them. Qt warns about it at compile time - so it's not a problem in this case.</p>
<ul>
<li>are you sure the signal <code>logMessage</code> is emitted?</li>
<li>if you are using a worker object, are you sure it emits the signal and that you connect to that signal, and not the encompassing thread?</li>
<li>are you moving <code>m_window3</code> to another thread <strong>after</strong> calling <code>connect()</code>? In that case, it may not work</li>
<li>does it work when you hard-code connection type to <code>Qt::QueuedConnection</code>?</li>
<li>is your main window performing some CPU-intensive task, like a long loop or something?</li>
</ul>
]]></description><link>https://forum.qt.io/post/525931</link><guid isPermaLink="true">https://forum.qt.io/post/525931</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Mon, 29 Apr 2019 13:12:50 GMT</pubDate></item></channel></rss>