QProgressBar with QNetworkReply
I am making an application which downloads zip files from internet and extracts it in a particular folder.
The code below shows a progressbar for downloading the files from internet.
what I want to do is to show a progressbar for both downloading and extracting, at present the progressbar for downloading is shown properly but unable to show it for extracting.
I want to set around 80% for downloading and the remaining 20% for extracting, how can I do this, can any one help me find out a solution for this.
- update::update(QWidget *parent) :
- ui(new Ui::update)
- bar = new QProgressBar (this);
- bar->setStyle(new QPlastiqueStyle);
- QNetworkRequest request(url);
- currentDownload = manager.get(request);
- connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)),
- connect(currentDownload, SIGNAL(finished()),
- void update::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
Thanks in advance.
Well, just increase the value until you reach the maximum.
- class update
- int _extractionStep;
- void update::startExtraction()
- // intermediateSteps depends on how your extraction works. if your
- // extractionProgress() slot is for example called every percent
- // extracted intermediateSteps will be 100.
- _extractionStep = (bar->maximum() - bar->value()) / intermediateSteps;
- void update::extractionProgress()
- bar->setValue(bar->()value + _extractionStep);
Thanks for the help your code is working as expected, but for extracting I am using QProcess::execute, but this makes the GUI and the progressbar inactive.
The GUI and progressbar becomes active after QProcess::execute have finished its work, also I cannot use QProcess::start as it goes in the background and returns the exit code immediately.
The reason why I am using QProcess::execute is that it returns the exit code after completing the work.
Is there any way that can make QProcess::execute and progressbar work simulataneuosly ?
Can I use QThread ? if yes, how ?
Thanks for the help.