title: Cannot create children for a parent that is in a different thread
body: <p>I have a QThread defined in MyThread.cpp and .h. There I have a private QTcpSocket.</p>
  
  <pre><code>class MyThread: public QThread {
  
      Q_OBJECT
  
  public:
      MyThread();
      virtual ~MyThread();
  
  public slots:
      void reconnect();
  signals:
  
  protected:
      void run(void);
  
  private:
      QTcpSocket *socket;
  };
  
  void MyThread::run(void) {
      bool connected = false;
  
      connected = prepareSocket(QString::fromLatin1((Global::directionIPSerialServer).toLocal8Bit().data()), 8008, socket);
  }
  </code></pre>
  
  <p>On the other hand, I have a set of functions defined in Functions.cpp and .h, which are not defined into a Functions class, but a namespace.</p>
  
  <pre><code>bool Functions::prepareSocket(QString address, int port, QTcpSocket *socket) {
      socket-&gt;connectToHost(address, port);
      if(!socket-&gt;waitForConnected(Global::maxTimueToConnectByTCP)){
          qDebug()&lt;&lt;"Error: "&lt;&lt;socket-&gt;errorString();
          return false;
      }
      return true;
  }
  </code></pre>
  
  <p>Then, correct me if I'm wrong, when I call a function into Functions to connect the MyThread's QTcpSocket to a host, I'm supposing I am on the same thread, since I'm calling the function from the thread I've created and not a different one.</p>
  
  <p>Despite this, on socket->connectToHost I am getting <strong>QObject: Cannot create children for a parent that is in a different thread.</strong> twice.</p>
  
  <p>Why is that? What's wrong?</p>