title: How to queue lambda function into Qt's event loop?
body: <p>Basically I need the same thing that is done like this in Java:</p>
  
  <pre><code>SwingUtilities.invokeLater(()-&gt;{/* function */});
  </code></pre>
  
  <p>Or like this in javascript:</p>
  
  <pre><code>setTimeout(()=&gt;{/* function */}, 0);
  </code></pre>
  
  <p>But with Qt and lambda. So some pseudocode:</p>
  
  <pre><code>Qt::queuePushMagic([]() { /* function */ });
  </code></pre>
  
  <p>As an additional complication, I need this to work in multithreaded context. What I'm actually trying to do is to automatically run certain methods in correct thread. What the code would then look:</p>
  
  <pre><code>SomeClass::threadSafeAsyncMethod() {
      if(this-&gt;thread() != QThread::currentThread()) {
          Qt::queuePushMagic([this]()=&gt;{ this-&gt;threadSafeAsyncMethod() });
          return;
      }
  }
  </code></pre>
  
  <p>How to do this? </p>