1. 程式人生 > >MovetoThread : Widgets cannot be moved to a new thread

MovetoThread : Widgets cannot be moved to a new thread

子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.