title: Run the code continuously until "Stop" is pressed
body: <p>I want to execute some code when I press a "Start" button and it have it continue running until I press "Stop".</p>
  
  <p>However, with the following code once I press "Start", I can't press "Stop" anymore:</p>
  
  <pre><code>void MainWindow::on_pushButton_clicked()
  {
      if (ui-&gt;pushButton-&gt;text()=="Start") {
          ui-&gt;pushButton-&gt;setText("Stop");
  
          vec spectrum_sensed,Sn,sigma,alpha;
          mat ydata;
          condition=true;
          while (condition) {
              cvec uhd_samples = to_cvec(randn(Nsamples),randn(Nsamples));
              ydata=spectrum-&gt;dft(uhd_samples,Ndft,Nband);
  
              myplot-&gt;Plot_data(spectrum_sensed,Ndft);
          }
       }
       else {
           ui-&gt;pushButton-&gt;setText("Start");
           condition=false;
           myplot-&gt;clear_plot();
       }
  }
  </code></pre>