<?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[Qt signals&#x2F;slot QThread &gt; GUI with lambdas functions]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I use Qt6.4 on Windows and I have a mistake from a signal/slot error.</p>
<p dir="auto">I have a QThread send a signal to my main GUI to show an error message :</p>
<pre><code>connect(m_uploaderServer, &amp;PortalUploader::error, [this](const QString &amp; message)
    {
        m_labelError-&gt;setText(message);
        m_labelError-&gt;show();
    });
</code></pre>
<p dir="auto">But when the signals is emitted, I have this error :</p>
<pre><code>[09/01/2023-13:46:33.439] QBasicTimer::start: Timers cannot be started from another thread
[09/01/2023-13:46:33.439] QObject::setParent: Cannot set parent, new parent is in a different thread
</code></pre>
<p dir="auto">I don't have this error if my QLabel is always visible (not use show() function).</p>
<p dir="auto">I don't understand this error. If I call directly from my thead the show() function, I understand why it is not correct, but in this case ?? Do I not use correctly signal/slot mechanism ? Somebody knows why ?</p>
<p dir="auto">Thanks</p>
<p dir="auto"><strong>[EDIT] : it seems that the lambda function that makes problem. When I use a member slot function, it's OK. Somebody knows why ?</strong></p>
<p dir="auto"><strong>[EDIT2] I found the answer. In <a href="https://wiki.qt.io/New_Signal_Slot_Syntax" target="_blank" rel="noopener noreferrer nofollow ugc">documentation</a>, it says:</strong></p>
<pre><code>the lambda will be called in the thread of the event loop of the object used as context).
</code></pre>
<p dir="auto">I keep my post, it can help someone else ...</p>
]]></description><link>https://forum.qt.io/topic/142071/qt-signals-slot-qthread-gui-with-lambdas-functions</link><generator>RSS for Node</generator><lastBuildDate>Sat, 09 May 2026 13:53:52 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/142071.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 09 Jan 2023 12:53:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qt signals&#x2F;slot QThread &gt; GUI with lambdas functions on Mon, 09 Jan 2023 13:29:41 GMT]]></title><description><![CDATA[<p dir="auto">Oh great, thanks for your answer !</p>
]]></description><link>https://forum.qt.io/post/743093</link><guid isPermaLink="true">https://forum.qt.io/post/743093</guid><dc:creator><![CDATA[OPit]]></dc:creator><pubDate>Mon, 09 Jan 2023 13:29:41 GMT</pubDate></item><item><title><![CDATA[Reply to Qt signals&#x2F;slot QThread &gt; GUI with lambdas functions on Mon, 09 Jan 2023 13:09:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/opit">@<bdi>OPit</bdi></a> said:</p>
<blockquote>
<p dir="auto">the lambda will be called in the thread of the event loop of the object used as context</p>
</blockquote>
<p dir="auto">A simple fix is to add that context i.e.</p>
<pre><code class="language-cpp">connect(m_uploaderServer, &amp;PortalUploader::error, m_labelError, [this](...
                                                  ^
                                                  here
</code></pre>
]]></description><link>https://forum.qt.io/post/743090</link><guid isPermaLink="true">https://forum.qt.io/post/743090</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Mon, 09 Jan 2023 13:09:13 GMT</pubDate></item></channel></rss>