MovetoThread : Widgets cannot be moved to a new thread

来源:互联网 发布:解放号平台知乎 编辑:程序博客网 时间:2024/06/04 19:15

子QObject必须在其parent关联的线程内创建,  调用moveToThread()的对象其parent必须为0

线程关联性(Thread Affinity)

使用QObject::moveToThread()可以将QObject对象从一个线程移动到另一个线程。


i receive an error message: QObject::moveToThread: Widgets cannot be moved to a new thread

How can i solve this problem?

Thank you in advance for your answers.


You can't move widgets into another thread - in order to keep user interface responsive, Qt needs to do all GUI work inside main thread.

If you have background work to do, then move background worker to other thread, and not the user interface.

                                                                                                                                           answerd  by Nemanja Boric