PyQt: RuntimeError: wrapped C/C++ object has been deleted

后端 未结 4 1731
醉酒成梦
醉酒成梦 2020-12-01 18:25

If I run this code:

    #!/usr/local/bin/    python3

import sys 
from PyQt4.QtCore import *
from PyQt4.QtGui import *


class Window(QMainWindow):

    def          


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 19:01

    This problem also occurs in PyQT5 when you run a continuous thread and close the mainwindow/dialog without closing thread first but in background the thread is processing. When you again open the window the second thread generated and delete the pre-existed widgets. You need to exit the thread first before re-run it. You can exit the thread by put the check on visibility of any widget in the mainwindow/dialog

                **if self.widget.isVisible() == False:
                    break**
    

提交回复
热议问题