title: QT: Connect signals to slots with move semantics
body: <p>Ok, i have something like this:</p>
  
  <pre><code>void EmailReceiverThread::foreachEmailAccount(ConfigEmailAccount account)
  {
      Email email;
      EmailReader emailReader(account);
      while (emailReader.pollEmail(email))
      {
          writeEmailToDatabase(email);
      }
  }
  </code></pre>
  
  <p>ForeachEmailAccount is a slot in EmailReceiverThread. It's called from the run() method:</p>
  
  <pre><code>GetConfigEmailDAO* accountReader = new GetConfigEmailDAO(type, m_channel);
  connect(accountReader, SIGNAL(emailAccount(ConfigEmailAccount)),
          this, SLOT(foreachEmailAccount(ConfigEmailAccount)), Qt::QueuedConnection);
  DbThread::postAction(accountReader);
  </code></pre>
  
  <p>GetConfigEmailDAO does a query, fetch the email account and do the emit:</p>
  
  <pre><code>emit emailAccount(account);
  </code></pre>
  
  <p>This works so far. The problem is, i'm copying the class ConfigEmailAccount. I would like avoid that perfomance hit. So, my idea is emit the account using c++11 move semantics:</p>
  
  <pre><code>emit emailAccount(std::move(account));
  </code></pre>
  
  <p>I rewrited the slots and signals with the new syntax:</p>
  
  <pre><code>void foreachEmailAccount(ConfigEmailAccount&amp;&amp; account);
  </code></pre>
  
  <p>Unfortunaly, this doesn't work. I have the next compilation error:</p>
  
  <pre><code>moc_emailreceiverthread.cpp:88: error: cannot bind ‘ConfigEmailAccount’ lvalue to ‘ConfigEmailAccount&amp;&amp;’
       case 1: _t-&gt;foreachEmailAccount((*reinterpret_cast&lt; ConfigEmailAccount(*)&gt;(_a[1]))); break;
  </code></pre>
  
  <p>What could i do?</p>
  
  <p>Minimal verifiable example here:</p>
  
  <pre><code>#include &lt;QCoreApplication&gt;
  #include &lt;QObject&gt;
  
  class ConfigEmailAccount
  {
      QString some_data;
  };
  
  class GetConfigEmailDAO : public QObject
  {
      Q_OBJECT
  public:
      void execute();
  
  signals:
      void emailAccount(ConfigEmailAccount&amp;&amp; account);
  };
  
  void GetConfigEmailDAO::execute()
  {
      ConfigEmailAccount account;
      emit emailAccount(std::move(account));
  }
  
  class EmailReceiverThread : public QObject
  {
      Q_OBJECT
  public:
      void execute();
  public slots:
      void foreachEmailAccount(ConfigEmailAccount&amp;&amp; account);
  };
  
  void EmailReceiverThread::execute()
  {
  
      GetConfigEmailDAO* accountReader = new GetConfigEmailDAO;
      connect(accountReader, SIGNAL(emailAccount(ConfigEmailAccount)),
              this, SLOT(foreachEmailAccount(ConfigEmailAccount)), Qt::QueuedConnection);
      accountReader-&gt;execute();
  }
  
  void EmailReceiverThread::foreachEmailAccount(ConfigEmailAccount&amp;&amp; account)
  {
  
  }
  
  int main(int argc, char *argv[])
  {
      QCoreApplication a(argc, argv);
      qRegisterMetaType&lt;ConfigEmailAccount&gt;("ConfigEmailAccount");
      EmailReceiverThread reader;
      reader.execute();
      return a.exec();
  }
  
  #include "main.moc"
  </code></pre>