Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change text displayed by QProgressBar

I use a QProgressBar to show the progress of a download operation. I would like to add some text to the percentage displayed, something like:

10% (download speed kB/s)

Any idea?

like image 720
Kazuma Avatar asked Dec 15 '11 02:12

Kazuma


1 Answers

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)+"%");
}
like image 90
Lwin Htoo Ko Avatar answered Oct 17 '22 13:10

Lwin Htoo Ko