Nominate our 2022 Qt Champions!

Change color of QProgressBar without stylesheet? (windows)

  • Dear Qt users, I know this has been asked 100 times but I've not seen a clear answer.
    I would like to change the color of a progress bar (basically red or green) but keep the OS original look (animation and so).
    I need this to work with Windows XP up to Windows 8, and it seem the "palette" option won't work for Windows Styles while it's ok with Plastic or clearlook styles.
    Is that right? Am I stuck using stylesheet?

  • According to the windows documentation that I a bit of googling turned up, changing the color of the bar to red or yellow should be doable by manipulating the progress bar state (to paused or error, instead of normal). However, there is no ready-made Qt API to do that.

  • Thanks for your answer. Any idea why palette tweaking is broken here? Is this going to be deprecated in a near future?

  • Depecated? No. But it is marked as "done".
    Palette tweaking doesn't work here, because Qt uses the native style rendering from Windows, and in this case, that does not support setting a custom color (other than through setting that state I mentioned). So, it's a limitation of the underlying platform. I guess it was deemed more important to have native rendering of widgets than to have complete control over the rendering. Being able to change the color would have meant trying to re-create the rendering and animation Windows does (and follow every change in subsequent releases).

Log in to reply