<?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[lambda expression capture]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">is there a way to do this??</p>
<pre><code>connect(this, &amp;MainWindow::loadFile, [viewer](QString value) {viewer-&gt;m_dataEngine-&gt;loadFile(value); });
</code></pre>
<p dir="auto">I'm in the MainWindow class and want to connect the loadFile signal from MainWindow with the loadFile function from GeometryEngine that is member of viewer.</p>
<p dir="auto">I thought i could make a lambda expression in viewer, but viewer does not hold an instance of MainWindow. So i hoped that there is a way to make it from MainWindow.</p>
]]></description><link>https://forum.qt.io/topic/75607/lambda-expression-capture</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 06:32:50 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/75607.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 29 Jan 2017 13:56:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to lambda expression capture on Mon, 30 Jan 2017 05:55:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qt-static-prgm">@<bdi>QT-static-prgm</bdi></a> Did you try it?<br />
If viewer is a member variable of MainWindow you can do it like this:</p>
<pre><code>connect(this, &amp;MainWindow::loadFile, [this](QString value) {viewer-&gt;m_dataEngine-&gt;loadFile(value); });
</code></pre>
<p dir="auto">But as <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said it would be better to implement a slot in Viewer.<br />
MainWindow should not care/know about Viewer internals like m_dataEngine.</p>
]]></description><link>https://forum.qt.io/post/372347</link><guid isPermaLink="true">https://forum.qt.io/post/372347</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 30 Jan 2017 05:55:16 GMT</pubDate></item><item><title><![CDATA[Reply to lambda expression capture on Sun, 29 Jan 2017 18:21:25 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">The clean way here would be to add a slot to your viewer class that will call whatever needed. The internals of that viewer class is of no concern to MainWindow.</p>
]]></description><link>https://forum.qt.io/post/372289</link><guid isPermaLink="true">https://forum.qt.io/post/372289</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 29 Jan 2017 18:21:25 GMT</pubDate></item></channel></rss>