I am running ubuntu 11.04. This is what my progress bars look like:
I am showing the progress bars in a batch processing window (one per batch item) and would like to use them as a status indicator (green while all is going well, red in case of errors, ...).
I have tried several suggestions, including the ones made to this almost identical question. Unfortunately, I couldn't make it work and the documentation on customizing QProgressBars doesn't help me either, so I would be very grateful for any suggestions as to what I'm doing wrong.
I have subclassed the QProgressBar as suggested and have tried using stylesheets as well as the palette (not at the same time but as alternatives). With stylesheets, I can't make it look anything like the regular progress bars. Changing the color is really all I want to do, so I figured it should be much easier to do that by use of a palette instead of a stylesheet, but with the palette nothing happens at all.
Here is one of the versions I've tried for the palette:
#include "myprogressbar.h"
#include <QtGui/QPalette>
MyProgressBar::MyProgressBar(QWidget *parent) :
QProgressBar(parent)
{}
void MyProgressBar::onProgress(int value, int maximum, QString phase)
{
setMaximum(maximum);
setValue(value);
setFormat(phase);
QPalette p = this->palette();
p.setColor(QPalette::Highlight, QColor(Qt::green));
this->setPalette(p);
}
...
I also tried the version suggested here, but that didn't help either.
palette
andsetPalette
says: Warning: Do not use this function in conjunction with Qt Style Sheets. Maybe that's the problem? In that case you could trystyle
andsetStyle
. But that's just my guess. – Helot