日志
QThread中提示QObject: Cannot create children for a parent that is in a different thread.警告
2016-01-22 15:24
运行线程时提示QObject: Cannot create children for a parent that is in a different thread.
查了查,原因应该是,在QThread中定义的所有东西都属于创建该QThread的线程。所以在构造函数中初始化的对象都应该是属于父线程的,那么在run中调用时就属于跨线程调用。所以把对象放到run中初始化就属于线程的了,调用时就不会出现跨线程调用的问题。 |
-
删除
ch593030323:想这样 run{QObject a; exec();}
2016-01-27 14:55 -