Answer the question
In order to leave comments, you need to log in
How to correctly terminate a QThread in pyqt5?
There is a program for pyqt5. It has a thread (qthread), in which it is necessary to perform some action with a certain peredachnostyu. I used QThread.msleep to define this period, and a flag to exit the while loop.
But if the period is long, then it will take a long time to exit the loop, and I want to terminate it as soon as I click on the button in the GUI (but don't kill it, start it again soon).
The source code here is pretty standard, I need more ideas.
Answer the question
In order to leave comments, you need to log in
Split QThread.msleep into several small segments and check whether to exit after each
Through the loop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question