The content of logging in python is displayed in the problem of multithreading in pyqt.

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

Apr.13,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b390ca-2c143.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b390ca-2c143.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?