QObject::setParent: Cannot set parent, new parent is in a different thread 2021-03-27 19:58:38.354 P

报错:

QObject::setParent: Cannot set parent, new parent is in a different thread
2021-03-27 19:58:38.354 Python[1331:38623] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
	0   AppKit                              0x00007fff22bd047f -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 352
	1   AppKit                              0x00007fff22bbb121 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1375
	2   AppKit                              0x00007fff22d7d377 -[NSPanel _initContent:styleMask:backing:defer:contentView:] + 50
	3   AppKit                              0x00007fff22bbabbb -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
	4   AppKit                              0x00007fff22d7d32c -[NSPanel initWithContentRect:styleMask:backing:defer:] + 64
	5   AppKit                              0x00007fff22ec51f4 -[NSWindow initWithContentRect:styleMask:backing:defer:screen:] + 52
	6   libqcocoa.dylib                     0x0000000136c61745 -[QNSPanel initWithContentRect:styleMask:backing:defer:screen:platformWindow:] + 197
	7   libqcocoa.dylib                     0x0000000136c4dcac _ZN12QCocoaWindow14createNSWindowEb + 1324
	8   libqcocoa.dylib                     0x0000000136c47672 _ZN12QCocoaWindow22recreateWindowIfNeededEv + 1266
	9   libqcocoa.dylib                     0x0000000136c470fe _ZN12QCocoaWindow10initializeEv + 318
	10  QtGui                               0x000000010abb7eb7 _ZN14QWindowPrivate6createEby + 151
	11  QtWidgets                           0x0000000109cfc771 _ZN14QWidgetPrivate6createEv + 1185
	12  QtWidgets                           0x0000000109cfb414 _ZN7QWidget6createEybb + 324
	13  QtWidgets                           0x0000000109d0e81d _ZN14QWidgetPrivate10setVisibleEb + 189
	14  QtWidgets                           0x0000000109ed557d _ZN7QDialog10setVisibleEb + 269
	15  QtWidgets                           0x0000000109ed4d80 _ZN7QDialog4execEv + 240
	16  QtWidgets                           0x0000000109f12a72 _ZL17showNewMessageBoxP7QWidgetN11QMessageBox4IconERK7QStringS5_6QFlagsINS1_14StandardButtonEES7_ + 354
	17  QtWidgets.abi3.so                   0x00000001091f0c4b _ZL24meth_QMessageBox_warningP7_objectS0_S0_ + 235
	18  Python                              0x00000001089af1bd _PyMethodDef_RawFastCallKeywords + 685
	19  Python                              0x00000001089ae5ba _PyCFunction_FastCallKeywords + 42
	20  Python                              0x0000000108a6d804 call_function + 724
	21  Python                              0x0000000108a6a7dd _PyEval_EvalFrameDefault + 25181
	22  Python                              0x00000001089ae9f0 function_code_fastcall + 128
	23  Python                              0x00000001089adfe4 _PyFunction_FastCallDict + 148
	24  Python                              0x00000001089af49f _PyObject_Call_Prepend + 143
	25  Python                              0x00000001089ae6e7 PyObject_Call + 135
	26  Python                              0x0000000108a6aaee _PyEval_EvalFrameDefault + 25966
	27  Python                              0x00000001089ae9f0 function_code_fastcall + 128
	28  Python                              0x0000000108a6d812 call_function + 738
	29  Python                              0x0000000108a6a7c3 _PyEval_EvalFrameDefault + 25155
	30  Python                              0x00000001089ae9f0 function_code_fastcall + 128
	31  Python                              0x0000000108a6d812 call_function + 738
	32  Python                              0x0000000108a6a7c3 _PyEval_EvalFrameDefault + 25155
	33  Python                              0x00000001089ae9f0 function_code_fastcall + 128
	34  Python                              0x00000001089adfe4 _PyFunction_FastCallDict + 148
	35  Python                              0x00000001089af49f _PyObject_Call_Prepend + 143
	36  Python                              0x00000001089ae6e7 PyObject_Call + 135
	37  Python                              0x0000000108af5b47 t_bootstrap + 71
	38  Python                              0x0000000108aac899 pythread_wrapper + 25
	39  libsystem_pthread.dylib             0x00007fff2035a950 _pthread_start + 224
	40  libsystem_pthread.dylib             0x00007fff2035647b thread_start + 15
)

原因

在使用pyqt的时候,我使用threading创建了一个线程然后在里面处理数据,处理的时候检测异常然后用qmessagebox提示错误信息时报错上面内容。
原因很简单不能在线程的函数里面使用qmessagebox

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

只会git clone的程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值