<?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[[closed] using lambdas]]></title><description><![CDATA[<p dir="auto">Hi i was wondering why i am getting this error:</p>
<p dir="auto">"error: C3493: 'd' cannot be implicitly captured because no default capture mode has been specified"</p>
<p dir="auto">when i try to use this line of code:</p>
<p dir="auto">@        QObject::connect(button, &amp;QPushButton::clicked, [this] () {<br />
Hi(d.absoluteFilePath());<br />
});<br />
@</p>
]]></description><link>https://forum.qt.io/topic/30316/closed-using-lambdas</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 23:15:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/30316.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Aug 2013 09:38:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [closed] using lambdas on Mon, 05 Aug 2013 11:29:01 GMT]]></title><description><![CDATA[<p dir="auto">We do not allow opening a new topic for the same issue you already have a topic on. Please continue the discussion "here":/forums/viewthread/30789/</p>
]]></description><link>https://forum.qt.io/post/189528</link><guid isPermaLink="true">https://forum.qt.io/post/189528</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Mon, 05 Aug 2013 11:29:01 GMT</pubDate></item><item><title><![CDATA[Reply to [closed] using lambdas on Mon, 05 Aug 2013 11:20:46 GMT]]></title><description><![CDATA[<p dir="auto">@<br />
QDir drives;<br />
foreach(QFileInfo d, drives.drives())<br />
{<br />
QFileIconProvider ip;</p>
<pre><code>    QVBoxLayout* buttonLayout = new QVBoxLayout;

    QPushButton *button = new QPushButton;
    button-&gt;setStyleSheet("border : 1px solid gray;"
                          "background: transparent;");
    button-&gt;setFixedSize(64,64);

    QLabel* iconLabel = new QLabel();
    iconLabel-&gt;setTextInteractionFlags(Qt::NoTextInteraction);
    iconLabel-&gt;setPixmap(ip.icon(d).pixmap(16,16,QIcon::Normal, QIcon::On));
    iconLabel-&gt;setAlignment(Qt::AlignCenter);
    iconLabel-&gt;setStyleSheet("border : 0px");
    QLabel* textLabel = new QLabel();
    textLabel-&gt;setTextInteractionFlags(Qt::NoTextInteraction);
    textLabel-&gt;setWordWrap(true);
    textLabel-&gt;setText(d.absoluteFilePath());
    textLabel-&gt;setAlignment(Qt::AlignCenter);
    textLabel-&gt;setStyleSheet("border : 0px;");

    buttonLayout-&gt;addWidget(iconLabel);
    buttonLayout-&gt;addWidget(textLabel);
    button-&gt;setLayout(buttonLayout);

    QObject::connect(button, &amp;QPushButton::clicked, [this] () {
        Hi(d.absoluteFilePath());
    });
    quickLinks-&gt;addWidget(button);
}
</code></pre>
<p dir="auto">@</p>
]]></description><link>https://forum.qt.io/post/189527</link><guid isPermaLink="true">https://forum.qt.io/post/189527</guid><dc:creator><![CDATA[Timmoth]]></dc:creator><pubDate>Mon, 05 Aug 2013 11:20:46 GMT</pubDate></item><item><title><![CDATA[Reply to [closed] using lambdas on Mon, 05 Aug 2013 11:14:14 GMT]]></title><description><![CDATA[<p dir="auto">How is d declared? Can you show a bit more of your code?</p>
<p dir="auto">You have to tell the lambda how to capture d.</p>
<p dir="auto">Assuming d is a local variable:<br />
@<br />
(1)   auto l = <a>&amp;d</a> { // d is captured by reference };<br />
(2)   auto l = <a>d</a> { // d is captured by value };<br />
(3)   auto l = <a>&amp;</a> { // all available variables are captured by reference };<br />
(4)   auto l = <a>=</a> { // all available variables are captured by value };<br />
@</p>
<p dir="auto">Or is d a member variable?</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/struct">@<bdi>struct</bdi></a> MyClass<br />
{<br />
int foo() {<br />
auto l = <a>this</a>{return d;};<br />
return l();<br />
};<br />
int d {};<br />
};@</p>
]]></description><link>https://forum.qt.io/post/189525</link><guid isPermaLink="true">https://forum.qt.io/post/189525</guid><dc:creator><![CDATA[PeerS]]></dc:creator><pubDate>Mon, 05 Aug 2013 11:14:14 GMT</pubDate></item></channel></rss>