title: Method to stop QThread that calls OpenCV functions
body: <p>I have a simple PyQT application which, on press of a &quot;calculate&quot; button calls a long-running function that performs some image processing using OpenCV. To allow the GUI to remain responsive, the long-running function is executed in a QThread (I implemented this by following <a href="https://realpython.com/python-pyqt-qthread/" rel="nofollow noreferrer">this excellent Real Python tutorial</a>.</p>
  <p>Ideally, I would like to be able to cancel the calculation (e.g. by pressing a &quot;cancel&quot; button). Given that the function is busy executing in OpenCV, is there a &quot;nice&quot;/safe way to do this? Or do we have to resort to a more brutal and risky method to kill the thread?</p>