<?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[Adding Lambda Expression as Slot]]></title><description><![CDATA[<p dir="auto">I want to create a Combobox and add to every combo box I add a function.</p>
<pre><code>connect(comboBox, SIGNAL(activated(QString)) ,this,  [](QString text){
        cout &lt;&lt; text.toUtf8().constData() &lt;&lt; endl;
    });
</code></pre>
<p dir="auto">But I always get as result : No matching member function for call to 'connect'</p>
]]></description><link>https://forum.qt.io/topic/85267/adding-lambda-expression-as-slot</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 22:44:25 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/85267.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Nov 2017 10:58:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Adding Lambda Expression as Slot on Wed, 22 Nov 2017 17:06:00 GMT]]></title><description><![CDATA[<p dir="auto">sorry I did not thought there´s an overload</p>
]]></description><link>https://forum.qt.io/post/427739</link><guid isPermaLink="true">https://forum.qt.io/post/427739</guid><dc:creator><![CDATA[sneubert]]></dc:creator><pubDate>Wed, 22 Nov 2017 17:06:00 GMT</pubDate></item><item><title><![CDATA[Reply to Adding Lambda Expression as Slot on Wed, 22 Nov 2017 13:26:17 GMT]]></title><description><![CDATA[<h4>I'll be <strong>that guy</strong>. I apologise in advance.</h4>
<p dir="auto">This is <strong>literally</strong> <a href="http://doc.qt.io/qt-5/qcombobox.html#activated-1" target="_blank" rel="noopener noreferrer nofollow ugc">spelled out for you in the docs</a>. you just need to copy-paste that code into your code. I can't think of a better way the docs could make this clear</p>
]]></description><link>https://forum.qt.io/post/427701</link><guid isPermaLink="true">https://forum.qt.io/post/427701</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Wed, 22 Nov 2017 13:26:17 GMT</pubDate></item><item><title><![CDATA[Reply to Adding Lambda Expression as Slot on Wed, 22 Nov 2017 11:12:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sneubert">@<bdi>sneubert</bdi></a> said in <a href="/post/427681">Adding Lambda Expression as Slot</a>:</p>
<blockquote>
<p dir="auto">the new syntax needs the address of a class member:<br />
connect(comboBox, &amp;QComboBox::activated ,this,  [](QString text){<br />
cout &lt;&lt; text.toUtf8().constData() &lt;&lt; endl;<br />
});</p>
</blockquote>
<p dir="auto">won't compile, since there are more than one activated() methods with different signatures. Thus the compiler won't know which one to link to.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said in <a href="/post/427682">Adding Lambda Expression as Slot</a>:</p>
<blockquote>
<p dir="auto">qOverload requires C++14.</p>
</blockquote>
<p dir="auto">Just a note:<br />
the function <code>qOverload&lt;&gt;()</code> requires C++14<br />
the helper class <code>QOverload&lt;&gt;::of()</code> also works since C++11</p>
]]></description><link>https://forum.qt.io/post/427683</link><guid isPermaLink="true">https://forum.qt.io/post/427683</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Wed, 22 Nov 2017 11:12:15 GMT</pubDate></item><item><title><![CDATA[Reply to Adding Lambda Expression as Slot on Wed, 22 Nov 2017 11:08:14 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Because you are trying to use an overload that doesn't exists:</p>
<pre><code>connect(comboBox, qOverload&lt;QString&gt;(&amp;QComboBox::activated), this, [](const QString &amp;text){
        cout &lt;&lt; text.toUtf8().constData() &lt;&lt; endl;
    });
</code></pre>
<p dir="auto">qOverload requires C++14.</p>
<p dir="auto">You don't even need the <code>this</code> parameter.</p>
<p dir="auto">For more information, see <a href="http://doc.qt.io/qt-5/signalsandslots-syntaxes.html" target="_blank" rel="noopener noreferrer nofollow ugc">here</a></p>
]]></description><link>https://forum.qt.io/post/427682</link><guid isPermaLink="true">https://forum.qt.io/post/427682</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 22 Nov 2017 11:08:14 GMT</pubDate></item><item><title><![CDATA[Reply to Adding Lambda Expression as Slot on Wed, 22 Nov 2017 11:07:25 GMT]]></title><description><![CDATA[<p dir="auto">the new syntax needs the address of a class member:</p>
<pre><code>connect(comboBox, &amp;QComboBox::activated ,this,  [](QString text){
        cout &lt;&lt; text.toUtf8().constData() &lt;&lt; endl;
    });
</code></pre>
]]></description><link>https://forum.qt.io/post/427681</link><guid isPermaLink="true">https://forum.qt.io/post/427681</guid><dc:creator><![CDATA[sneubert]]></dc:creator><pubDate>Wed, 22 Nov 2017 11:07:25 GMT</pubDate></item><item><title><![CDATA[Reply to Adding Lambda Expression as Slot on Wed, 22 Nov 2017 11:10:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/domididongo">@<bdi>Domididongo</bdi></a> said in <a href="/post/427677">Adding Lambda Expression as Slot</a>:</p>
<blockquote>
<p dir="auto">But I always get as result : No matching member function for call to 'connect'</p>
</blockquote>
<pre><code>connect(comboBox, QOverload&lt;QString&gt;::of(&amp;QComboBox::activated) , this,  [](const QString &amp; text) {
        cout &lt;&lt; text.toUtf8().constData() &lt;&lt; endl;
    });
</code></pre>
]]></description><link>https://forum.qt.io/post/427680</link><guid isPermaLink="true">https://forum.qt.io/post/427680</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Wed, 22 Nov 2017 11:10:34 GMT</pubDate></item><item><title><![CDATA[Reply to Adding Lambda Expression as Slot on Wed, 22 Nov 2017 11:04:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/domididongo">@<bdi>Domididongo</bdi></a> Remove this:</p>
<pre><code>connect(comboBox, SIGNAL(activated(QString)) ,[](QString text){
        cout &lt;&lt; text.toUtf8().constData() &lt;&lt; endl;
    });
</code></pre>
]]></description><link>https://forum.qt.io/post/427679</link><guid isPermaLink="true">https://forum.qt.io/post/427679</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Wed, 22 Nov 2017 11:04:18 GMT</pubDate></item></channel></rss>