Answer the question
In order to leave comments, you need to log in
How to implement PYQT5 Realtime ProgressBar?
There is a PyQt5 application, when you click on a button, a cycle is launched with a length of about a thousand operations. I need the progressbar to be updated after each scrolling of the loop, at the moment this is implemented as follows:
class MyForm(QtWidgets.QDialog): #Окно отправки сообщения
def __init__(self, parent = None):
super(MyForm, self).__init__(parent)
self.form = Ui_Dialog()
self.form.setupUi(self)
self.progressBar = QtWidgets.QProgressBar(self) #Создание прогресбара
self.progressBar.setGeometry(QtCore.QRect(80, 740, 811, 23))
self.btn = QPushButton("SomebodyButton")
self.btn.pressed.connect(self.start)
def SomebodyButton(self):
procent = 100 / len(mas) #Расчёт прогрес бара
value = 0 #Начальное значение
for i in range(mas):
somebodyFunc()
for i in range(round(procent) + 1):
value += 1
self.progressBar.setValue(value)
time.sleep(0.1)
Answer the question
In order to leave comments, you need to log in
Run from the QThread button click handler, in which to loop and send a signal to the main thread at each iteration, and in the main thread to update the progressbar in the signal handler.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question