<?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[QObject&#x27;s QThread from shared library]]></title><description><![CDATA[<p dir="auto">Hello everyone! Questions about classes inherited from QObject in shared library and it's usage in the main application. Currently on Qt 6.5.0.</p>
<p dir="auto">I have a shared library with test class like this:</p>
<pre><code>class LIB_EXPORT Tester: public QObject {
    Q_OBJECT
public:
    Tester(QObject* parent = nullptr):QObject(parent){};
    ~Tester() = default;
};
</code></pre>
<p dir="auto">In main application I link the library and use it:</p>
<pre><code>Tester test;
qDebug() &lt;&lt; QThread::currentThread();
qDebug() &lt;&lt; test.thread();
</code></pre>
<p dir="auto">And output is like this:</p>
<pre><code>QThread(0x2b484981b50)
QThread(0x2b4849c3990)
</code></pre>
<p dir="auto">So I cannot correctly work with this class, e.g. cannot move it to desired thread and so on. Even if in my main application I create derived class from Tester, it will be created in another thread.<br />
Is it correct behaviour? If so, what is the correct way to work with?</p>
]]></description><link>https://forum.qt.io/topic/164770/qobject-s-qthread-from-shared-library</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 07:08:25 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164770.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 10 Jun 2026 11:41:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QObject&#x27;s QThread from shared library on Fri, 12 Jun 2026 04:17:53 GMT]]></title><description><![CDATA[<p dir="auto">You <em>must not</em> mix debug and release libraries on windows with MSVC.</p>
]]></description><link>https://forum.qt.io/post/838698</link><guid isPermaLink="true">https://forum.qt.io/post/838698</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 12 Jun 2026 04:17:53 GMT</pubDate></item><item><title><![CDATA[Reply to QObject&#x27;s QThread from shared library on Thu, 11 Jun 2026 14:47:13 GMT]]></title><description><![CDATA[<p dir="auto">Still doesn't know, if this is a correct behaviour (can be logically explained, I mean), but the issue was quite simple. Somehow library's versions were mixed and debug shared library was linked to app's release version and vice versa. In this case QObjects from library (including inherited classes' objects) are created in a different QThread.</p>
]]></description><link>https://forum.qt.io/post/838684</link><guid isPermaLink="true">https://forum.qt.io/post/838684</guid><dc:creator><![CDATA[St.Stanislav]]></dc:creator><pubDate>Thu, 11 Jun 2026 14:47:13 GMT</pubDate></item><item><title><![CDATA[Reply to QObject&#x27;s QThread from shared library on Wed, 10 Jun 2026 18:13:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> said in <a href="/post/838661">QObject's QThread from shared library</a>:</p>
<blockquote>
<p dir="auto">You must be doing something in your Tester ctor.</p>
</blockquote>
<p dir="auto">In the code above you can see that there is totally empty ctor :)<br />
But looks like that I have found the issue. Need to check it tomorrow.</p>
]]></description><link>https://forum.qt.io/post/838663</link><guid isPermaLink="true">https://forum.qt.io/post/838663</guid><dc:creator><![CDATA[St.Stanislav]]></dc:creator><pubDate>Wed, 10 Jun 2026 18:13:45 GMT</pubDate></item><item><title><![CDATA[Reply to QObject&#x27;s QThread from shared library on Wed, 10 Jun 2026 16:37:28 GMT]]></title><description><![CDATA[<p dir="auto">This is working fine for me</p>
<pre><code>int main(int argc, char* argv[])
{
    QApplication app(argc, argv);

    QObject obj;
    qDebug() &lt;&lt; QThread::currentThread();
    qDebug() &lt;&lt; obj.thread();
    return 0;
}
</code></pre>
<p dir="auto">--&gt;<br />
QThread(0x26c3915b030, name = "Qt mainThread")<br />
QThread(0x26c3915b030, name = "Qt mainThread")</p>
<p dir="auto">You must be doing something in your Tester ctor.</p>
]]></description><link>https://forum.qt.io/post/838661</link><guid isPermaLink="true">https://forum.qt.io/post/838661</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Wed, 10 Jun 2026 16:37:28 GMT</pubDate></item></channel></rss>