title: Use of deleted function error in qt C++ signals and slots
body: <p>Could anyone please help me why I am getting this deleted function error even though I am passing parameters as pointer references (*&amp;) ? This is a simple project working with multithreading in Qt, I just want to experiment sharing and modifying objects between parent and child threads. I am new in Qt, I am using Qt 5.9.2 with GCC 4.9.4 on Ubuntu Linux 14.04.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>===== Controller.hpp ===========
  #pragma once
  
  #include "data.hpp"
  
  #include &lt;QObject&gt;
  #include &lt;QThread&gt;
  
  class Controller : public QObject
  {
      Q_OBJECT
      QThread workerThread;
  public:
      explicit Controller(QObject *parent = nullptr);
      ~Controller();
  
  signals:
      void operate(Data*&amp; data);
  
  public slots:
      void handleResults(int idx);
  
  private:
      Data _data;
  };
  
  ===== Controller.cpp ===========
  #include "controller.hpp"
  #include "worker.hpp"
  
  #include &lt;QDebug&gt;
  
  Controller::Controller(QObject *parent) : QObject(parent)
  {
      Worker *worker = new Worker;
      worker-&gt;moveToThread(&amp;workerThread);
      connect(&amp;workerThread, &amp;QThread::finished, worker, &amp;QObject::deleteLater);
      connect(this, &amp;Controller::operate, worker, &amp;Worker::doWork);
      connect(worker, &amp;Worker::resultReady, this, &amp;Controller::handleResults);
      workerThread.start();
  
      emit operate(&amp;_data);
  }
  
  Controller::~Controller()
  {
      workerThread.quit();
      workerThread.wait();
  }
  
  void Controller::handleResults(int idx)
  {
      qDebug() &lt;&lt; _data.at(idx);
  }
  
  ===== Worker.hpp ===========
  #pragma once
  
  #include "data.hpp"
  
  #include &lt;QObject&gt;
  
  class Worker : public QObject
  {
      Q_OBJECT
  public:
      explicit Worker(QObject *parent = nullptr);
  
  signals:
      void resultReady(int idx);
  
  public slots:
      void doWork(Data*&amp; data);
  };
  
  ===== Worker.cpp ===========
  #include "worker.hpp"
  
  Worker::Worker(QObject *parent) : QObject(parent)
  {
  }
  
  void Worker::doWork(Data*&amp; data)
  {
      data-&gt;insertVal(10);
      emit resultReady(data-&gt;getSize());
  }
  
  ===== Data.hpp ===========
  #pragma once
  
  #include &lt;QObject&gt;
  #include &lt;QVector&gt;
  
  class Data : public QObject
  {
      Q_OBJECT
  public:
      explicit Data(QObject *parent = nullptr);
  
      void insertVal(int i);
      int getSize() const { return _intVec.size(); }
  
  private:
      QVector&lt;int*&gt; _intVec;
  };
  
  ===== Data.cpp ===========
  #include &lt;QDebug&gt;
  
  #include "data.hpp"
  
  Data::Data(QObject *parent) : QObject(parent)
  {
  }
  
  void Data::insertVal(int i)
  {
      _intVec &lt;&lt; &amp;i;
      qDebug() &lt;&lt; "Data inserted: " &lt;&lt; i;
  }
  
  ===== main.cpp ===========
  #include "controller.hpp"
  #include "data.hpp"
  
  #include &lt;QCoreApplication&gt;
  
  int main(int argc, char *argv[])
  {
      qRegisterMetaType&lt;Data&gt;("Data");
  
      QCoreApplication a(argc, argv);
  
      Controller con;
      return a.exec();
  }
  </code></pre>
  
  <p>I am getting these errors:</p>
  
  <pre><code>/home/raze/Qt/5.9.2/gcc_64/include/QtCore/qmetatype.h:765: error: use of deleted function ‘Data::Data(const Data&amp;)’
               return new (where) T(*static_cast&lt;const T*&gt;(t));
  
  /home/raze/Qt/5.9.2/gcc_64/include/QtCore/qobject.h:454: error: ‘QObject::QObject(const QObject&amp;)’ is private
       Q_DISABLE_COPY(QObject)
                      ^
                                                             ^
  /home/raze/Documents/Qt_projects/PracThread/data.hpp:6: error: within this context
   class Data : public QObject
         ^
  
  /home/raze/Documents/Qt_projects/PracThread/data.hpp:6: error: use of deleted function ‘QObject::QObject(const QObject&amp;)’
  </code></pre>