<?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[Unresolved external symbol when connecting with new syntax]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I have a class that inherits from QLineEdit to implement clicked signal :</p>
<pre><code>#if defined(LD_LIBRARY)
#  define LD_DLL Q_DECL_EXPORT
#else
#  define LD_DLL Q_DECL_IMPORT
#endif

class LdLineEdit: public QLineEdit
{
    Q_OBJECT
public:
    LD_DLL explicit LdLineEdit( QWidget *aParent = nullptr );
signals:
    LD_DLL void LdClicked();
protected:
    void mouseReleaseEvent(QMouseEvent *){emit LdClicked();}
}
</code></pre>
<p dir="auto">And when I try to connect to this signal with the new syntax :</p>
<pre><code>connect(&amp;mLESerial, &amp;LdLineEdit::LdClicked,this,&amp;PrReportViewer::LESerialTextEdited);
</code></pre>
<p dir="auto">I have this error :</p>
<pre><code>PrReportViewer.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const LdLineEdit::staticMetaObject" (?staticMetaObject@LdLineEdit@@2UQMetaObject@@B)
</code></pre>
<p dir="auto">However, if i use the old syntax :</p>
<pre><code>connect( &amp;mLESerial, SIGNAL( LdClicked() ), this, SLOT( LESerialTextEdited() ) ) ;
</code></pre>
<p dir="auto">it works (it compiles, and its actually connected)</p>
<p dir="auto">I need the new syntax to plug a Lambda instead of that slot, and it would be nice to understand anyway.</p>
]]></description><link>https://forum.qt.io/topic/79811/unresolved-external-symbol-when-connecting-with-new-syntax</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 23:41:17 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/79811.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 31 May 2017 16:04:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 17:26:52 GMT]]></title><description><![CDATA[<p dir="auto">No problem. As to why it works with the old syntax - it works because there's no compile time checking and all is done in runtime.</p>
]]></description><link>https://forum.qt.io/post/396548</link><guid isPermaLink="true">https://forum.qt.io/post/396548</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Wed, 31 May 2017 17:26:52 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 17:24:54 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the help !</p>
]]></description><link>https://forum.qt.io/post/396547</link><guid isPermaLink="true">https://forum.qt.io/post/396547</guid><dc:creator><![CDATA[Mwoua]]></dc:creator><pubDate>Wed, 31 May 2017 17:24:54 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 17:21:27 GMT]]></title><description><![CDATA[<p dir="auto">The rule is you need to export Qt's methods and variables from your class - the ones <code>Q_OBJECT</code> introduces (in this case the <code>staticMetaObject</code>, see your linker error in the OP), so when working with <code>QObject</code>s always export the whole class.</p>
]]></description><link>https://forum.qt.io/post/396546</link><guid isPermaLink="true">https://forum.qt.io/post/396546</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Wed, 31 May 2017 17:21:27 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 17:19:25 GMT]]></title><description><![CDATA[<p dir="auto">Ok, is there a rule to export a whole class or just a part of it?</p>
]]></description><link>https://forum.qt.io/post/396544</link><guid isPermaLink="true">https://forum.qt.io/post/396544</guid><dc:creator><![CDATA[Mwoua]]></dc:creator><pubDate>Wed, 31 May 2017 17:19:25 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 17:18:24 GMT]]></title><description><![CDATA[<p dir="auto">Export the whole class, not only a handful of methods.</p>
<p dir="auto"><em>Edit: Crossposted with our Ronin, but it happens. ;)</em></p>
]]></description><link>https://forum.qt.io/post/396543</link><guid isPermaLink="true">https://forum.qt.io/post/396543</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Wed, 31 May 2017 17:18:24 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 17:17:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mwoua">@<bdi>Mwoua</bdi></a> said in <a href="/post/396539">Unresolved external symbol when connecting with new syntax</a>:</p>
<blockquote>
<p dir="auto">LdLineEdit is in a dll</p>
</blockquote>
<p dir="auto">BINGO!<br />
you should export the whole class</p>
<pre><code>class LD_DLL LdLineEdit: public QLineEdit
{
    Q_OBJECT
Q_DISABLE_COPY(LdLineEdit)
public:
LdLineEdit(QWidget* parent = Q_NULLPTR)
:QLineEdit(parent)
{}
signals:
    void LdClicked();
protected:
    void mouseReleaseEvent(QMouseEvent *){emit LdClicked();}
}

</code></pre>
]]></description><link>https://forum.qt.io/post/396542</link><guid isPermaLink="true">https://forum.qt.io/post/396542</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Wed, 31 May 2017 17:17:37 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 17:17:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/taz742">@<bdi>Taz742</bdi></a><br />
See first post</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vronin">@<bdi>VRonin</bdi></a><br />
The constructor is there in my class, I forgot it because I wanted to simplify (I'll edit my first post)</p>
<p dir="auto">The macro is :</p>
<pre><code>#if defined(LD_LIBRARY)
#  define LD_DLL Q_DECL_EXPORT
#else
#  define LD_DLL Q_DECL_IMPORT
#endif
</code></pre>
<p dir="auto">LdLineEdit is in a dll that I use in my other function</p>
<p dir="auto">Same issue with the function in protected.</p>
<p dir="auto">EDIT : it might be linked to the dll, if I do this inside a function of LdLineEdit :</p>
<pre><code>connect( this, &amp;LdLineEdit::LdClicked, this, &amp;LdLineEdit::ThisValueChanged);
</code></pre>
<p dir="auto">It compiles (ThisValueChanged is private slot of LdLineEdit)</p>
]]></description><link>https://forum.qt.io/post/396539</link><guid isPermaLink="true">https://forum.qt.io/post/396539</guid><dc:creator><![CDATA[Mwoua]]></dc:creator><pubDate>Wed, 31 May 2017 17:17:31 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 16:47:56 GMT]]></title><description><![CDATA[<p dir="auto">Strange error. replace <code>private slots:</code> with <code>protected:</code> btw, the event is not a slot. Also add a constructor or you'll potentially break parent/child dependency.</p>
<p dir="auto">Last question, what is <code>LD_DLL</code>?</p>
<pre><code class="language-cpp">class LdLineEdit: public QLineEdit
{
    Q_OBJECT
Q_DISABLE_COPY(LdLineEdit)
public:
LdLineEdit(QWidget* parent = Q_NULLPTR)
:QLineEdit(parent)
{}
signals:
    LD_DLL void LdClicked();
protected:
    void mouseReleaseEvent(QMouseEvent *){emit LdClicked();}
}
</code></pre>
]]></description><link>https://forum.qt.io/post/396536</link><guid isPermaLink="true">https://forum.qt.io/post/396536</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Wed, 31 May 2017 16:47:56 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 16:40:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mwoua">@<bdi>Mwoua</bdi></a><br />
And What is LdLineEdit ?</p>
]]></description><link>https://forum.qt.io/post/396535</link><guid isPermaLink="true">https://forum.qt.io/post/396535</guid><dc:creator><![CDATA[Taz742]]></dc:creator><pubDate>Wed, 31 May 2017 16:40:44 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 16:22:37 GMT]]></title><description><![CDATA[<p dir="auto">LdLineEdit</p>
]]></description><link>https://forum.qt.io/post/396533</link><guid isPermaLink="true">https://forum.qt.io/post/396533</guid><dc:creator><![CDATA[Mwoua]]></dc:creator><pubDate>Wed, 31 May 2017 16:22:37 GMT</pubDate></item><item><title><![CDATA[Reply to Unresolved external symbol when connecting with new syntax on Wed, 31 May 2017 16:11:00 GMT]]></title><description><![CDATA[<p dir="auto">What type is <code>mLESerial</code>? <code>LdLineEdit</code> or <code>LdLineEdit*</code>?</p>
]]></description><link>https://forum.qt.io/post/396530</link><guid isPermaLink="true">https://forum.qt.io/post/396530</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Wed, 31 May 2017 16:11:00 GMT</pubDate></item></channel></rss>