在run内创建也不行,报QObject: Cannot create children for a parent that is in a different thread. (Parent is readWriteThread(0x21080b80), parent's thread is QThread(0x20fd2530), current thread is readWriteThread(0x21080b80)
angelus
2019-11-07 11:39
wcrqpdb:在run内创建也不行,报QObject: Cannot create children for a parent that is in a different thread. (Parent is readWriteThread(0x21080b80), parent's thread is QThread(0x20fd2530), current thread is readWriteThread(0x21080b80) (2019-11-07 11:32)
wcrqpdb:在run内创建也不行,报QObject: Cannot create children for a parent that is in a different thread. (Parent is readWriteThread(0x21080b80), parent's thread is QThread(0x20fd2530), current thread is readWriteThread(0x21080b80) (2019-11-07 11:32)
zi.h [attachment=21036] zu.h [attachment=21037] main [attachment=21038] zi.cpp [attachment=21039] zu.cpp [attachment=21040] 报 QObject: Cannot create children for a parent that is in a different thread. (Parent is zi(0x7cf9c0), parent's thread is QThread(0x176f60), current thread is zi(0x7cf9c0) 原程序[attachment=21041]
圣域天子
2019-11-07 16:35
QTimer 在线程中不要用 new QTimer k; 就可以了。run结束后它自动释放。
不过 k 如果关联信号的话,应该依旧会存在。
你的需求的实现方式应该调整一下,在线程中使用 QTimer 发时间信号,应该是没意义了。
wcrqpdb
2019-11-07 18:02
圣域天子:QTimer 在线程中不要用 new QTimer k; 就可以了。run结束后它自动释放。 不过 k 如果关联信号的话,应该依旧会存在。 ....... (2019-11-07 16:35)
我要定时处理数据
dbzhang800
2019-11-07 19:00
wcrqpdb:zi.h [图片] zu.h [图片] main ....... (2019-11-07 15:02)
你在run()内写下列代码,错了。run()函数内是次线程,但是this不在次线程内,不能作为父对象。 new QTimer(this)