January 2016
Beginner
512 pages
12h 35m
English
In order to achieve this, we can use the reply's downloadProgress() signal. As the first argument, it passes the information on how many bytes have already been received and as the second argument, how many bytes there are in total. This gives us the possibility to indicate the progress of the download with QProgressBar. As the passed arguments are of the qint64 type, we can't use them directly with QProgressBar, as it only accepts int. So, in the connected slot, we first calculate the percentage of the download progress:
void SomeClass::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { qreal progress = (bytesTotal < 1) ? 1.0 : bytesReceived * 100.0 / bytesTotal; progressBar->setValue(progress ...