D
D
del4pp2020-05-14 17:09:12
Python
del4pp, 2020-05-14 17:09:12

PyQT5 how to make ProgressBar and lcdnumber work in thread?

Hello.
I am making a program on pyqt5, everything works correctly without threads, but when the thread is started, the progressbar and lcdnumber elements do not work.
I debugged the variables with a print, everything outputs as it should, but the elements do not work.

Stream code:

class YourThreadName(QtCore.QThread):
    def __init__(self):
        QtCore.QThread.__init__(self)

    def __del__(self):
        self.wait()

    def run(self):
        M_Start_Screen().startTest()


StartTest function code:
def startTest(self):
        ...
        for index in range(100):
             ...
            self.progressBar.setValue(index)
            self.lstSender.display(Index)
            self.lstSender.repaint()
            index += 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bbkmzzzz, 2020-05-14
@bbkmzzzz

Widgets can only be accessed from the main thread, in order for everything to work from a third-party thread, send a signal and subscribe to it in the main thread.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question