QObject: Cannot create children for a parent that is in a different thread

参考:

https://blog.csdn.net/qq_24890953/article/details/55880043

https://stackoverflow.com/questions/3268073/qobject-cannot-create-children-for-a-parent-that-is-in-a-different-thread

https://www.cnblogs.com/findumars/p/9361993.html  此链接的问题:moveToThread可以改变此对象和其子对象的线程依附性,但inline explicit WorkerA(QObject *parent = 0)这个构造函数并未指定其父对象。

可以利用构造函数的初始化列表指定构造函数,如inline explicit WorkerA(QObject *parent = 0):QObject(parent)

 

 

设计原则参考:《Qt Creator快速入门_第三版__霍亚飞编著》19.2小节

 

原文地址:https://www.cnblogs.com/lh03061238/p/13793578.html