QObject: Cannot create children for a parent that is in a different thread
-
hello, I want to use "QtcpSocket" and "movetoThread" to detach from qt main thread. and then I executed "connecttohost(....)" but the executed result shows that "QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTcpSocket(0x1de2b6796e0), parent's thread is QThread(0xbca74ffc00), current thread is QThread(0x1de2b60ee70)" . Does Anybody knows the reason?
-
hello, I want to use "QtcpSocket" and "movetoThread" to detach from qt main thread. and then I executed "connecttohost(....)" but the executed result shows that "QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTcpSocket(0x1de2b6796e0), parent's thread is QThread(0xbca74ffc00), current thread is QThread(0x1de2b60ee70)" . Does Anybody knows the reason?
When you move your socket to another thread then you should also access the socket from this thread and not from the main thread.
-
When you move your socket to another thread then you should also access the socket from this thread and not from the main thread.
@Christian-Ehrlicher thanks. it had solved.
-
W weigang.lee has marked this topic as solved on