Change text in the QProgressBar

make the QProgressBar text visible.

QProgressBar *progBar = new QProgressBar();
progBar->setTextVisible(true);

to show the download progress

void Widget::setProgress(int downloadedSize, int totalSize)
{
    double downloaded_Size = (double)downloadedSize;
    double total_Size = (double)totalSize;
    double progress = (downloaded_Size/total_Size) * 100;
    progBar->setValue(progress);

    // ******************************************************************
    progBar->setFormat("Your text here. "+QString::number(progress)+"%");
}

You could calculate the download speed yourself, then construct a string thus:

QString text = QString( "%p% (%1 KB/s)" ).arg( speedInKbps );
progressBar->setFormat( text );

You'll need to do this every time your download speed needs updating, however.


I know this is super late, but in case someone comes along later. Since PyQT4.2, you can just setFormat. For example to have it say currentValue of maxValue (0 of 4). All you need is

yourprogressbar.setFormat("%v of %m")