前几日在使用qt多线程时,需要在子线程中发送信号到主线程,再用槽函数处理,更新界面。虽然在理论上感觉是可以的,但是出现了以下错误
Error: Cannot create children for a parent that is in a different thread
原因是不同线程间信号接收引发的错误
只需要在connect的第5个参数设置为Qt::QueuedConnection
connect(this, SIGNAL(OriginalDownOver()), this, SLOT(OriginDealDown()), Qt::QueuedConnection);
就这样的小问题困扰了我许久,特此记录一下。
全部评论 (共 1 条评论)