Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QProgressBar font color change during progress

    General and Desktop
    5
    7
    7888
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      goocreations 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.

      1 Reply Last reply Reply Quote 0
      • A
        andre 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.

        1 Reply Last reply Reply Quote 0
        • G
          goocreations last edited by

          Ok, cool. Thanx

          1 Reply Last reply Reply Quote 0
          • D
            dangelog 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

            Software Engineer
            KDAB (UK) Ltd., a KDAB Group company

            1 Reply Last reply Reply Quote 0
            • E
              erapid 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

              1 Reply Last reply Reply Quote 0
              • G
                goocreations 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.

                1 Reply Last reply Reply Quote 0
                • Jeroentjehome
                  Jeroentjehome 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

                  Greetz, Jeroen

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post