pythonguis / feedback

Corrections & suggestions for Python GUIs tutorials on pythonguis.com
1 stars 0 forks source link

pyqtSignal() must pass the correct type, or the signal emitted would be converted to random numbers #7

Open heximing opened 7 months ago

heximing commented 7 months ago

This this tutorial: "Multithreading PyQt5 applications with QThreadPool" in "PyQt5 Tutorial / Threads & Processes" URL: www.pythonguis.com/tutorials/multithreading-pyqt-applications-qthreadpool

in class WorkerSignals(QObject):, we define progress = pyqtSignal(int). in class MainWindow(QMainWindow): in def execute_this_fn(self, progress_callback):, we emit the signal progress_callback.emit(n*100/4). However, n*100/4 is float. We must emit the correct type, i.e. int(n*100/4), or the signal will be converted to a random number.