Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProgressBar font color change during progress

QProgressBar font color change during progress

Scheduled Pinned Locked Moved General and Desktop
7 Posts 5 Posters 8.4k Views
  • 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 Offline
    G Offline
    goocreations
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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
      0
      • G Offline
        G Offline
        goocreations
        wrote on last edited by
        #3

        Ok, cool. Thanx

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          [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
          0
          • E Offline
            E Offline
            erapid
            wrote on last edited by
            #5

            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
            0
            • G Offline
              G Offline
              goocreations
              wrote on last edited by
              #6

              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
              0
              • JeroentjehomeJ Offline
                JeroentjehomeJ Offline
                Jeroentjehome
                wrote on last edited by
                #7

                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
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved