Hi there. I'd like to know what is the proper way of using moveToThread function. I have QTcpSocket object as a member of QThread derived class. I've got some warning messages about thread affinity. To solve that I call moveToThread inside my thread class:
class MyDownloadingThread
: public QThread{
//...
protected:
//...
}
//....
MyDownloadingThread::MyDownloadingThread(ParentThread *parentThread)
{
this->parentThread = parentThread;
this->socket.moveToThread(this);
}
class MyDownloadingThread: public QThread
{
//...
protected:
QTcpSocket socket;
//...
}
//....
MyDownloadingThread::MyDownloadingThread(ParentThread *parentThread)
{
this->parentThread = parentThread;
this->socket.moveToThread(this);
}
To copy to clipboard, switch view to plain text mode
Is it correct? Or maybe I should call moveToThread after starting the target thread?
Bookmarks