Ok but moving the socket was not my point, I try that with your code :

main.c
Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include "clientsocket.h"
  3.  
  4. #include <QThread>
  5. #include <QtDebug>
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. QCoreApplication a(argc, argv);
  10.  
  11. ClientSocket m_ClientSocket;
  12. QThread *thread = new QThread(&a);
  13. thread->start();
  14. // now we got another thread
  15. m_ClientSocket.moveToThread(thread);
  16.  
  17. qDebug() << "Main thread is " <<QThread::currentThreadId();
  18.  
  19. bool bConnected = m_ClientSocket.connectToHost("10.33.17.37", 8000);
  20. qDebug() << "Connexion done";
  21. if (bConnected)
  22. {
  23. qDebug() << "Ask for Id";
  24. m_ClientSocket.write("*rem\n*idn?\n", 10);
  25. }
  26.  
  27. // For testing don't do a exec() just wait for msec
  28. // Without the processEvent() qDebug not displaying anything but
  29. // the threadid prove the reception is done in the other thread
  30. thread->wait(500); // After 500ms I should have the response or I give up.
  31. a.processEvents();
  32. thread->quit();
  33. thread->wait(100);
  34. return 0;
  35. }
To copy to clipboard, switch view to plain text mode 

clientsocket.h
Qt Code:
  1. #ifndef CLIENTSOCKET_H
  2. #define CLIENTSOCKET_H
  3.  
  4. #include <QTcpSocket>
  5.  
  6. class ClientSocket: public QObject
  7. {
  8. Q_OBJECT
  9.  
  10. public:
  11. ClientSocket();
  12. bool connectToHost(QString host, int port);
  13. void write(const char* Data,unsigned int nBytes);
  14. //void run();
  15. public slots:
  16. void test();
  17.  
  18. private:
  19. QTcpSocket* m_socket;
  20. };
  21.  
  22.  
  23. #endif // CLIENTSOCKET_H
To copy to clipboard, switch view to plain text mode 


clientsocket.c
Qt Code:
  1. #include "clientsocket.h"
  2.  
  3. #include <QDebug>
  4. #include <QThread>
  5.  
  6. ClientSocket::ClientSocket() : QObject()
  7. ,m_socket(new QTcpSocket())
  8. {
  9. connect(m_socket, SIGNAL(readyRead()), this, SLOT(test()), Qt::QueuedConnection);
  10. }
  11.  
  12. bool ClientSocket::connectToHost(QString host, int port)
  13. {
  14. if (port == 0) return false;
  15. m_socket->connectToHost(host, port);
  16. return m_socket->waitForConnected(1000);
  17. }
  18.  
  19. void ClientSocket::write(const char* Data,unsigned int nBytes)
  20. {
  21. if (m_socket && (m_socket->state() == QAbstractSocket::ConnectedState))
  22. {
  23. m_socket->write(Data);
  24. m_socket->flush();
  25. }
  26. }
  27.  
  28. void ClientSocket::test()
  29. {
  30. qDebug() << "I got something here!!!" << QThread::currentThreadId() ;
  31. }
To copy to clipboard, switch view to plain text mode 

This is the output:
Starting /disk2/local/qt/TestDebug/TestDebug...
Main thread is 3070105296
Connexion done
Ask for Id
I got something here!!! 3068005232
/disk2/local/qt/TestDebug/TestDebug exited with code 0
There is something strange with the qDebug in the second thread, it will display nothing until we call a processEvent() but the thread Id displayed in the readyRead connected slot proves that it's the second thread .

I don't know if you can use it like this in your app but It seems to work fine for me except that I can explain the strange behavior with the qDebug in the second thread.
(You have to take care of the cross thread call in a second time)

Hope it can help