stackoverflow found the processing of logging
but copying the original code will prompt
QObject::connect: Cannot queue arguments of type "QTextBlock"
(Make sure "QTextBlock" is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type "QTextCursor"
(Make sure "QTextCursor" is registered using qRegisterMetaType().)
follow the search and find the safer way to modify the user interface is to send a signal signal to the UI window
to sum up, the code is as follows
class MyThead(QtCore.QThread):
updated = QtCore.pyqtSignal(str)
def __init__(self, mainUI, msg):
super().__init__()
self.updated.connect(mainUI.plainTextEdit.appendPlainText)
self.msg = msg
def run(self):
self.updated.emit(self.msg)
class QPlainTextEditLogger(logging.Handler):
def __init__(self, mainUI):
super().__init__()
self.mainUI = mainUI
def emit(self, record):
msg = self.format(record)
_thread = MyThead(self.mainUI, msg)
_thread.start()
The code cannot be executed, the window is destroyed directly, and no error is reported