title: Qt Slots and C++11 lambda
body: <p>I have a QAction item that I initialize like follows:</p>
  
  <pre><code>QAction* action = foo-&gt;addAction(tr("Some Action"));
  connect(action, SIGNAL(triggered()), this, SLOT(onSomeAction()));
  </code></pre>
  
  <p>And then onSomeAction looks something like:</p>
  
  <pre><code>void MyClass::onSomeAction()
  {
      QAction* caller = qobject_cast&lt;QAction*&gt;(sender());
      Q_ASSERT(caller != nullptr);
  
      // do some stuff with caller
  }
  </code></pre>
  
  <p>This works fine, I get the <code>caller</code> object back and I'm able to use it as expected. Then I try the C++11 way to connect the object like such:</p>
  
  <pre><code>connect(action, &amp;QAction::triggered, [this]()
  {
      QAction* caller = qobject_cast&lt;QAction*&gt;(sender());
      Q_ASSERT(caller != nullptr);
  
      // do some stuff with caller
  });
  </code></pre>
  
  <p>But <code>caller</code> is always null and thus the <code>Q_ASSERT</code> triggers. How can I use lambdas to get the sender?</p>