thread->moveToThread(thread);
class Worker : public QObject{ Q_OBJECTpublic slots: void work();signals: void finished();};void Worker::work(){ // do some work emit finished();}int main(){ QThread thread; Worker w; w.moveToThread(&thread); QObject::connect(&thread, SIGNAL(started()), &w, SLOT(work())); QObject::connect(&w, SIGNAL(finished()), &thread, SLOT(quit())); thread.start();}
C++ (Qt) qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
C++ (Qt) fSocket = new QTcpSocket(this);