title: Insert text in while(1) loop to texteditor in QT
body: <p>Am trying to print "Some text" to QTextBrowser, continuously for "n" time. Where "n" is integer. For this I have used QTimer::SingleShot for timing. Once the timeout  is triggered a FLAG is set to false and this "FLAG" is monitored in while loop to break when FLAG is false and it shall insert the text till FLAG is set to FALSE. Initial value for FLAG is true.</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include &lt;QThread&gt;
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      FLAG = true;
  
  }
  
  void MainWindow::on_pushButton_clicked()
  {
      ui-&gt;pushButton-&gt;setEnabled(false);
     RunTheTimer();
      int counter = 0;
  
      do
      {
          ui-&gt;textBrowser-&gt;insertPlainText(QString("Inside While loop %1 \n").arg(counter++));
          counter++;
      }while(FLAG);
  
      FLAG = true;
  
  }
  void MainWindow::RunTheTimer()
  {
       ui-&gt;textBrowser-&gt; insertPlainText("Timer Started");
      QTimer::singleShot(60000, this, SLOT(Update()));// One Minute
  
  }
  
  void MainWindow::Update()
  {
     ui-&gt;textBrowser-&gt; insertPlainText("Timeout signal triggered");
      ui-&gt;pushButton-&gt;setEnabled(true);
     FLAG = false;
  }
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  </code></pre>
  
  <p>Application is getting Hang, When I click Pushbutton.
  After debugging I observed, timeout is not triggering once the execution is entered to while(1) loop and application is not able to insert any text inside while(1) loop. Why this behavior? What am I doing wrong?</p>
  
  <p>Thanks. </p>