title: How to Break an Infinite Loop using QPushButton?
body: <p>I have an infinite loop, inside the loop I want to insert a state whenever I click a button, it will break the current loop.
  I've tried several ways like:</p>
  
  <pre><code>if(ui-&gt;btnStop-&gt;isDown())
    {
       break;
    }
  
  
  if(ui-&gt;btnStop-&gt;isChecked())
        {
           break;
        }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>if(cv::waitKey(10)&gt;=0)
  {
      break;
  }
  </code></pre>
  
  <p>But, it doesn't work.
  I wonder why cv::waitKey doesn't work in Qt, but in a non-Qt project it will work flawlessly.
  Are there any other way to break an infinite loop with a QPushButton?
  Any help would be appreciated.</p>