QProgressBar font color change during progress
-
wrote on 9 Jan 2011, 19:58 last edited by
I've googled this, but I can;t find anything on this topic:
I have a QProgressBar, customized with a style sheet. Is it possible to change the color of the text (eg: 50%) of the progress bar, when the chunk hits the text.
For instance, I have a progress bar which fills with a black chunk. The background of the progress bar is white. At the start I want the font color to be black, but when the chunk hits the text (more or less 50%), the color should change to white so that you can still read the text. If possible: can only that part of the text covered by the chunk be re-colored, not the entire text?
Thanks for any suggestions.
-
wrote on 9 Jan 2011, 20:51 last edited by
This is handled by the style you're using. Try to see if another style's rendering suits you better, or, if not, implement a (proxy) style to handle it yourself. There is no simple setting for this.
-
wrote on 9 Jan 2011, 20:58 last edited by
Ok, cool. Thanx
-
wrote on 9 Jan 2011, 21:43 last edited by
[quote author="goocreations" date="1294603132"]I've googled this, but I can;t find anything on this topic:
I have a QProgressBar, customized with a style sheet. Is it possible to change the color of the text (eg: 50%) of the progress bar, when the chunk hits the text.
For instance, I have a progress bar which fills with a black chunk. The background of the progress bar is white. At the start I want the font color to be black, but when the chunk hits the text (more or less 50%), the color should change to white so that you can still read the text. If possible: can only that part of the text covered by the chunk be re-colored, not the entire text?
Thanks for any suggestions.[/quote]
AFAIK it's not currently possible.
[Edited to add] See http://labs.qt.nokia.com/2007/06/12/styling-qprogressbar-and-qscrollbar/#comment-880
-
wrote on 10 Jan 2011, 01:08 last edited by
Style sheet is evil ;)
You can inherit QProgressBar and use QPainter::setClipRect in paintEvent to do what you wish
If you like, I can post the example of class that we use in our project
-
wrote on 10 Jan 2011, 06:11 last edited by
No, its fine. I just thought there is a easy way to do it with a style sheet, but I will code it know. Thanks anyway.
-
wrote on 24 Oct 2011, 08:23 last edited by
Hmm, why is stylesheet evil?? Even in Designer you can edit it and on run time alter it if you like. Works fine with me. So Erapid, what is so terrible about it?
greetz