Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Cant change color of progressBar
Engelard last edited by Engelard
Simpliest thing, and i was done that(with other widgets, not progBar) many many times.
And now for some reason i cant change styleSheet of my progress bar, and particulary - background color(which is green by default). Here is the code:
But i can change just color, which will change text of numbers with % sign in to red.
There's a whole blog post about styling QProgressBar that might interest you.
Hope it helps
@SGaist well, the only thing i understand - script "background" or "background-color" change background of main Widget of it, not second progress-bar which moves. Need to find out how call they that progress bar which moves(green one).
I find out. It called "chunk".
But here is a problem , if i'll changing it, it will broke whole stylesheet of widget, i mean, margins, no borders now, align of numbers with % changed,and even size.
New question. How can i find out original, default stylesheet of progressBar? In Qt documentation no such info...
There is no original stylesheet
Its painted via QStyle functions/ QPainter / natively
So if you apply a stylesheet, you must apply enough of it to look
good again/close to original.
Here's an example of customizing the progress bar, including the chunk that may help:
@ambershark yea, i'm already saw that couple hour ago, but i just wanted change green color to red, or some else, i dont want to create whole new SS for my ProgressBar.
There is no hope for that.
The progressbar color is typically controlled by the window manager. So changing it means Qt no longer uses it's regular drawing routines and instead using the CSS ones. You're pretty much stuck with a custom widget or a full new styling.
Custom progress bar widget would make it pretty easy to change the color and keep a similar look though. You would override it's drawing and just draw the chunks with the QPen/QBrush with the color you wanted. Not too much work, but neither is styling it in CSS.