title: Get real upload progress in QT
body: <p>So I want to upload a file using this code in qt:</p>
  
  <pre><code>    QFile *file =  new QFile(this-&gt;itemsToUpload.at(index));
      QUrl url("http://leonardogalli.ch/beta/upload_single.php");
      QNetworkRequest request(url);
  
      QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
      QHttpPart loginPart;
      /* password */
      loginPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"password\""));
      loginPart.setBody("pass");
      multiPart-&gt;append(loginPart);
      loginPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"path\""));
      loginPart.setBody(this-&gt;paths.at(index).toLocal8Bit());
      qDebug() &lt;&lt; this-&gt;paths.at(index).toLocal8Bit();
      multiPart-&gt;append(loginPart);
      QHttpPart filePart;
      /* important that the files[] variable have the brackets, for PHP to interpret correctly */
      filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"uploaded\"; filename=\""+ file-&gt;fileName() + "\""));
      qDebug() &lt;&lt; "form-data; name=\"file1\"; filename=\""+ file-&gt;fileName() + "\"";
      file-&gt;open(QIODevice::ReadOnly);
      //qDebug() &lt;&lt; file-&gt;readAll();
      filePart.setBodyDevice(file);
      file-&gt;setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart
      multiPart-&gt;append(filePart);
  
  
  
      QNetworkReply* reply = networkManager-&gt;post(request, multiPart);
      this-&gt;currentReply = reply;
      multiPart-&gt;setParent(reply); // delete the multiPart with the reply
      QObject::connect(reply,SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(uploadProgress(qint64,qint64)));
      QObject::connect(reply, SIGNAL(finished()), this, SLOT(finished()));
      QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));
  }
  void UploadManager::uploadProgress(qint64 bytesSent, qint64 bytesTotal)
  {
      if(bytesSent!=0 &amp;&amp; bytesTotal != 0)
      {
      qDebug() &lt;&lt; "Uploaded:" &lt;&lt; bytesSent &lt;&lt; " bytes of total: " &lt;&lt; bytesTotal &lt;&lt; "diff to total: " &lt;&lt; bytesTotal-this-&gt;totalSize;
      qint64 bytesDiff = bytesSent - this-&gt;lastUlSize;
      this-&gt;UlSize += bytesDiff;
      this-&gt;lastUlSize = bytesSent;
      int timeDiff = QDateTime::currentMSecsSinceEpoch()/1000-this-&gt;time;
      if(timeDiff!= 0 &amp;&amp; bytesSent!=0 &amp;&amp; bytesTotal != 0)
      {
          qDebug() &lt;&lt; "Uploadspeed: " &lt;&lt; ((this-&gt;UlSize/timeDiff));
  
          qint64 remainingUl = this-&gt;totalSize - this-&gt;UlSize;
          qint64 speed = ((this-&gt;UlSize/timeDiff)); //Download Speed in B/s
          int remainingTimeSec = remainingUl/speed;
          qDebug() &lt;&lt; "Remaining time: " &lt;&lt;  this-&gt;readableTime(remainingTimeSec) &lt;&lt; " percentage: " &lt;&lt; (this-&gt;UlSize/this-&gt;totalSize)*100;
          float percentage = ((float)this-&gt;UlSize/(float)this-&gt;totalSize)*100;
          emit uploadProg(this-&gt;niceSpeed(speed), this-&gt;readableTime(remainingTimeSec), percentage);
      }
      }
  }
  </code></pre>
  
  <p>The problem is there is a really long delay between the last uploadProgress signal and the finished signal. According to <a href="https://stackoverflow.com/questions/24363568/qt-qnetworkaccessmanager-long-delay-to-emit-finished-signal" title="this">this</a> question this is due to the uploadProgress not being the progress when a chunk of data has finished uploading. So how would I get the real uploadProgress, when a chunk is finished uploading?</p>
  
  <h2>Update 1:</h2>
  
  <p>On mac it seems to work perfectly, so why wont it work on windows?</p>