QProgressBar font color change during progress



  • 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.



  • 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.



  • Ok, cool. Thanx



  • [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



  • 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



  • 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.



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.