I know that Qt uses by default the OS style for decorating a QProgressBar.
I am wondering if there is a way to change the color of a QProgressBar while keeping the OS style.
I tried several methods as showned below.
Changing the palette:
QPalette palette = myProgressBar->palette();
palette.setBrush(QPalette::Highlight, someColor); // setColor() did the same
myProgressBar->setPalette(palette);
Changing directly the style:
QPalette palette = myProgressBar->palette();
palette.setBrush(QPalette::Highlight, someColor); // setColor() did the same
myProgressBar->style()->polish(palette);
But both methods was completely ignored and nothing has changed.
The only way I found to change the color of the QProgressBar is by setting a style sheet via setStyleSheet(). The problem is that it ignores the OS style at the same time.
I think it is possible to approximately replicate the OS style in a style sheet but I don't know if it is possible to directly apply the OS style and only change the color palette.
I would be very grateful for any helpful answer.
EDIT: The OS is not fixed. I am trying to make it work under Windows but the application may/will run under another OS (some Linux distribution).