我的原始问题在这里:解构对象会出现QCoreApplication::sendEvent: "不能向由不同线程拥有的对象发送事件
我看到很多人说,将QObject移动到工作线程后,就不能从GUI线程中删除它。
就像这样:
//In the GUI thread
QThread* workerThread = new QThread(this);
worker->moveToThread(workerThread);
...
//Still in the Gui thread but somewhere else
delete worker;//Is this wrong?
在这种情况下,如果我需要销毁worker时停止workerthread,那么我的唯一选择是执行以下操作:
connect(worerThread,&finished,worker,&deleteLater)?
...
//when I no longer need the worker & the worker thread
workerThread->quit();
workerThread->wait();
workerThread
的事件循环)。 - ChristianworkerThread
еҸӘжү§иЎҢиҝҷдёҖдёӘд»»еҠЎеҗ—пјҹеҰӮжһңжҳҜиҝҷж ·пјҢиҜ·жҹҘзңӢQt ConcurrentгҖӮйӮЈд№ҲдҪ е°ұдёҚйңҖиҰҒеҲ йҷӨд»»дҪ•дёңиҘҝдәҶгҖӮ - Christian