QProgressBar problem with uploading

Posted by rolanddd on Stack Overflow See other posts from Stack Overflow or by rolanddd
Published on 2010-04-02T12:57:29Z Indexed on 2010/04/02 13:03 UTC
Read the original article Hit count: 162

Filed under:
|
|
|

Hey all!

I show my code first, then I explain my problem:

...
// somewhere in the constructor
    progressBar = new QProgressBar(this);
    progressBar->setMinimum(0);
    progressBar->setMaximum(100);
...
    connect(&http, SIGNAL(dataSendProgress(int, int)), this, SLOT(updateProgressBar(int, int)));
...
void MainWindow::updateProgressBar(int bytesSent, int total)
{
        progressBar->setMaximum(total);
        progressBar->setValue(bytesSent);
}

So this is how I try to make my progressBar being updated when I upload a file. The problem is, it won't do the job. When it starts uploading, I set the value of the progress bar to 0, then (thanks to this slot) it won't actually show the progress, but will jump to 100% immediately (even before it finished uploading).

I already checked the HTTP Client example, and copied the progress bar part, it is for downloading, and more or less is the same as for uploading but it uses the dataReadProgress signal (needed for downloading) AND it works perfectly.
Does anybody know how to solve this for uploading?

© Stack Overflow or respective owner

Related posts about qt

Related posts about c++