title: Qt show constantly updating percentage in status bar
body: <p>I have a program which load a file, does some calculations on the data, saves the data in memory and prints out to a text file.</p>
  
  <p>I want to show the percentage of the processing progress in the status bar, I am using the following code:</p>
  
  <pre><code>    percent=file.pos()*10000/file.size();
      if((percent!=progress)&amp;&amp;(percent%5==1)){
          progress=percent/100;
          qDebug() &lt;&lt; progress;
          progresslabel-&gt;setText(QString("Loading File: %1 \%").arg(progress));
  </code></pre>
  
  <p>Which is a part of the following function:</p>
  
  <pre><code>void MainWindow::CalcIntegral(){
  
      int percent,progress;
      progress=1;
      SingleLineData.resize(GRIDDIM*GRIDDIM);
      SingleLineData.fill(0);
  
      QString test;
      QString inputfile = QFileDialog::getOpenFileName(
                  this,
                  tr("Open Data File"),
                  "/Users",
                  "Data files (*.txt)"
                  );
  
      if(inputfile == NULL)
          return;
          QFile file(inputfile);
  
    qDebug()&lt;&lt;"TEST";
          if(!file.open(QIODevice::ReadOnly)){
          }
      //    QTextStream in(&amp;file);
      OpenFileData = new QTextStream(&amp;file);
  
          double buffer;
          OpenFilePositions.resize(0);
          OpenFilePositions.push_back(-2);
          OpenFileData-&gt;readLine();
          progresslabel = new QLabel;
          ui-&gt;statusBar-&gt;addWidget(progresslabel);
          while(!OpenFileData-&gt;atEnd()){
  
              for(int i=0; i&lt;512; i++){
                  *OpenFileData &gt;&gt; buffer;
                  SingleLineData[i]+=buffer;
              }
  
              percent=file.pos()*10000/file.size();
              if((percent!=progress)&amp;&amp;(percent%5==1)){
                  progress=percent/100;
                  qDebug() &lt;&lt; progress;
                  progresslabel-&gt;setText(QString("Loading File: %1 \%").arg(progress));
  
  
              }
  
      OpenFilePositions.push_back(OpenFilePositions.last()+6*(NUMBER_OF_AFE_CHIPS*AFECHANNELS)+1);
  
    }
          OpenFilePositions.removeFirst();
          OpenFilePositions.push_front(0);
  
    qDebug() &lt;&lt; SingleLineData;
    qDebug() &lt;&lt; OpenFilePositions.size();
    // ************* file output **************************************************
  
  //  QString filename = QFileDialog::getSaveFileName(
  //              this,
  //              tr("Save File"),
  //              "/Users",
  //              "Text files (*.txt)"
  //              );
  
  
    QString OutputFile = inputfile;
    OutputFile.replace(".txt","_integral.int");
    QFile fileout(OutputFile);
    fileout.open(QFile::WriteOnly);
    QTextStream out(&amp;fileout);
    for(int i=0;i&lt;512;i++){
        out&lt;&lt;SingleLineData[i]&lt;&lt;"\t";
    }
  
    fileout.close();
  }
  </code></pre>
  
  <p>I can see the percentage constantly update in the console/application output thanks to <code>qDebug()</code> however the status bar only updates once the processing is complete and jumps right to 99%.</p>
  
  <p>Any ideas how to make it update real time?</p>
  
  <p>Cheers</p>