Python if I run insade threading module .setText("<a href='{}'>{}</a>".format(a,b)) crashing program

0

Python if I run insade threading module label.setText("{}".format(a,b)) crashing program

(For example);

    class Window(QWidget):

    def __init__(self):
        super().__init__()
        self.setUi()
        self.show()

    def label(self):
        self.a.setText("<a href='{}'>{}</a>".format("https://www.mertmekatronik.com","Mert Mekatronik"))

    def setUi(self):
        self.a = QLabel()
        self.a.setText("")
        q = QVBoxLayout()
        q.addWidget(self.a)
        self.setLayout(q)
        threading.Thread(target=self.label).start()

def main():
    app = QApplication(sys.argv)
    window = Window()
    sys.exit(app.exec())

if __name__ == "__main__":
    main()

Error; Process finished with exit code -1073741819 (0xC0000005) How i solve this?

python-3.x
multithreading
pyqt5
asked on Stack Overflow Jun 13, 2020 by KutaN

1 Answer

0

You should use QThreads for threading in Qt applications. Also you should only edit widgets from your main thread! Use signals to move results from your worker threads to your main thread.

answered on Stack Overflow Jun 13, 2020 by zariiii9003

User contributions licensed under CC BY-SA 3.0