QObject: Cannot create children for a parent that is in a different thread. (Parent is QLabel(0x2c19

使用PyQt5的时候,在使用多线程的时候,会报错:

QObject: Cannot create children for a parent that is in a different thread.
(Parent is QLabel(0x2c1964c0ba0), parent’s thread is QThread(0x2c18e6db8e0), current thread is QThread(0x2c197fc1fc0)

原因:GUI相关的对象不能在非GUI的线程创建和使用,是非线程安全的,也就是在线程里,我们不要创建控件或者操作控件对象,我是在线程里对一个label控件做了写入文本,self.safty_check_tip.setText( “检测中…”)),我放在线程开启之前就可以了,但是我在线程里最后也这样操作了,但是没有报这个问题。

发布了79 篇原创文章 · 获赞 9 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/s_daqing/article/details/104927064