PDA

View Full Version : set QProgressDialog. progress indicator color?



Gokulnathvc
17th February 2012, 07:18
how to set QProgressDialog. progress indicator color?

qlands
17th February 2012, 13:05
Do you mean the progress bar on the QProgressDialog? If so, you can set its palette Highlight color to the color you want.

Maybe QProgressDialog constructs the progress bar with a default bar. To replace it just create a new QProgressBar* , change its color and replace it with setBar ( QProgressBar * bar )



QProgressBar * myBar = new QProgressBar(this);

QPalette palette1;
QBrush brush2(QColor(192, 0, 0, 255)); //Some red color
brush2.setStyle(Qt::SolidPattern);
palette1.setBrush(QPalette::Active, QPalette::Highlight, brush2);
palette1.setBrush(QPalette::Inactive, QPalette::Highlight, brush2);
QBrush brush3(QColor(204, 199, 197, 255));
brush3.setStyle(Qt::SolidPattern);
palette1.setBrush(QPalette::Disabled, QPalette::Highlight, brush3);
myBar->setPalette(palette1);

MyProgressDialog.setBar(myBar);



Carlos

ChrisW67
20th February 2012, 02:15
You can use a style sheet

steps
15th March 2012, 10:47
Carlos, I tried what you suggested in a class that is derived from QProgressBar. This is my code:


void MyProgressBar::onStarted()
{
setFormat(tr("Preparing"));

QPalette p = this->palette();
QBrush greenBrush(QColor(0, 255, 0, 255));
greenBrush.setStyle(Qt::SolidPattern);
p.setBrush(QPalette::Active, QPalette::Highlight, greenBrush);
p.setBrush(QPalette::Inactive, QPalette::Highlight, greenBrush);
this->setPalette(p);
}
But the color doesn't change. Maybe you can spot my mistake?