Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How To Change QProgressBar Chunk Color, While Retaining Shimmer Animation
Forum Updated to NodeBB v4.3 + New Features

How To Change QProgressBar Chunk Color, While Retaining Shimmer Animation

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 2 Posters 468 Views 1 Watching
  • 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.
  • N Offline
    N Offline
    NelsonA
    wrote on last edited by NelsonA
    #1

    Hello,

    We notice the following animation play (before we've changed the style sheet) for a QProgressBar:

    84e9c50d-4e0c-4622-b82f-7263b7af0609-image.png

    Note: Notice the whitish glow that passes over the QProgressBar.

    However, after we've changed the chunk style sheet to another color (for example: red to denote an error):

    myProgressBar.setStyleSheet("QProgressBar::chunk{background-color: rgb(255, 0, 0);}")

    ...we notice that the shimmer animation (that plays every couple of seconds) no longer plays:

    1ab5a303-8040-42e0-8899-9ec507a1b49c-image.png

    Question: Is there a way to change the chunk color while continuing to play the shimmer animation?

    Note: My OS is Windows 11 Professional.

    Thank you,
    Nelson

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Qt stylesheet style does not use the native style hence the change of look.
      One thing you can try is using the palette and change the highlight color. Note that it might not work as styles are free to ignore elements from the palette to conform to the OS.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NelsonA
        wrote on last edited by
        #3

        Hello SGaist,

        Thank you for the prompt reply.

        Unfortunately, it doesn't look like your solution works (likely meaning that this is simply not possible with Qt at the moment - if ever).

        I tried the following:

        progress_bar_palette = my_progress_bar.palette()
        progress_bar_palette.setColor(QPalette.Highlight, QColor(Qt.red))
        my_progress_bar.setPalette(progress_bar_palette)

        ...but my progress bar remained green.

        Thank you for at least trying to provide me with a solution.

        Regards,
        Nelson

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by SGaist
          #4

          The other alternative is to write your own custom style (KDAB has an excellent article on why).

          You can start with QProxyStyle and check the implementation of the windows related styles to see how the progress bar are painted and adapt that to your needs.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • N Offline
            N Offline
            NelsonA
            wrote on last edited by
            #5

            Hello SGaist,

            Thank you for the article on custom styles.

            Regards,
            Nelson

            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