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. Problem with styling undetermined QProgressBar

Problem with styling undetermined QProgressBar

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.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.
  • TobiasT Offline
    TobiasT Offline
    Tobias
    wrote on last edited by
    #1

    Hallo,
    I have trouble setting the style for a undetermined QProgressBar.
    From the docs I know there should be an option.
    https://doc.qt.io/qt-5/qprogressbar.html#setRange
    https://doc.qt.io/qt-5/stylesheet-reference.html there it is mentioned that there is a thing called :indeterminate

    The main problem is that my QProgressBar::chunk only partly applies to the undetermined progress bar.
    My style looks like this:

          m_pProgressBar->setStyleSheet(QString::fromUtf8(R"(
            QProgressBar {
              border-image: url(:/images/launcher/ProgressBar_BG.png);
              font-family: "Verdana";
              font-size: 13px;
              font-weight: bold;
              color: #bfbfbf;
              text-align: center;
            }
            QProgressBar::chunk {
              border-image: url(:/images/launcher/ProgressBar.png);
              margin-top: 2px;
              margin-left: 2px;
              margin-bottom: 3px;
              margin-right: 3px;
            }
          )"));
    

    The QProgressBar::chunk style works perfectly.
    But the funny thing is, for the undetermined version it takes nearly everything form QProgressBar::chunk but margin-left: 2px; and margin-right: 3px;. So the endless running progress indicator overlaps with my border from the ProgressBar_BG.png.
    I'm using Qt 5.5 and that can't be changed currently.

    I have already tried QProgressBar::chunk:indeterminate and QProgressBar:indeterminate and some other less likely combinations. Also with : and ::. Might be that I missed the single version that works.

    So if you have any advice or suggestion how to fix that I'm happy to give it a try!

    Thanks a lot.
    Cheers
    Tobias

    JonBJ 1 Reply Last reply
    0
    • TobiasT Offline
      TobiasT Offline
      Tobias
      wrote on last edited by
      #4

      I found the solution:
      https://doc.qt.io/qt-5/stylesheet-customizing.html#box-model
      The bug in the current code was that that we tried to use margins instead of borders.

            m_pProgressBar->setStyleSheet(QString::fromUtf8(R"(
              QProgressBar {
                border-image: url(:/images/launcher/ProgressBar_BG.png);
                font-family: "Verdana";
                font-size: 13px;
                font-weight: bold;
                color: #bfbfbf;
                text-align: center;
                border-top: 2px;
                border-left: 2px;
                border-bottom: 3px;
                border-right: 3px;
              }
              QProgressBar::chunk {
                border-image: url(:/images/launcher/ProgressBar.png);
              }
            )"));
      

      Setting the borders correct in the Style and not using margins in the ```Style::chunk```` solved the problem.

      1 Reply Last reply
      1
      • TobiasT Tobias

        Hallo,
        I have trouble setting the style for a undetermined QProgressBar.
        From the docs I know there should be an option.
        https://doc.qt.io/qt-5/qprogressbar.html#setRange
        https://doc.qt.io/qt-5/stylesheet-reference.html there it is mentioned that there is a thing called :indeterminate

        The main problem is that my QProgressBar::chunk only partly applies to the undetermined progress bar.
        My style looks like this:

              m_pProgressBar->setStyleSheet(QString::fromUtf8(R"(
                QProgressBar {
                  border-image: url(:/images/launcher/ProgressBar_BG.png);
                  font-family: "Verdana";
                  font-size: 13px;
                  font-weight: bold;
                  color: #bfbfbf;
                  text-align: center;
                }
                QProgressBar::chunk {
                  border-image: url(:/images/launcher/ProgressBar.png);
                  margin-top: 2px;
                  margin-left: 2px;
                  margin-bottom: 3px;
                  margin-right: 3px;
                }
              )"));
        

        The QProgressBar::chunk style works perfectly.
        But the funny thing is, for the undetermined version it takes nearly everything form QProgressBar::chunk but margin-left: 2px; and margin-right: 3px;. So the endless running progress indicator overlaps with my border from the ProgressBar_BG.png.
        I'm using Qt 5.5 and that can't be changed currently.

        I have already tried QProgressBar::chunk:indeterminate and QProgressBar:indeterminate and some other less likely combinations. Also with : and ::. Might be that I missed the single version that works.

        So if you have any advice or suggestion how to fix that I'm happy to give it a try!

        Thanks a lot.
        Cheers
        Tobias

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @Tobias
        The bad news is that https://www.qtcentre.org/threads/33170-Customizing-indeterminate-QProgressBar asked and tried the same as you to style the :indetermiate back in 2010, but got no replies :(

        I would have thought it is supposed to be QProgressBar:indeterminate, no mention of ::chunk, (it applies the the QProgressBar as a whole), but I think you've both tried that.

        TobiasT 1 Reply Last reply
        0
        • JonBJ JonB

          @Tobias
          The bad news is that https://www.qtcentre.org/threads/33170-Customizing-indeterminate-QProgressBar asked and tried the same as you to style the :indetermiate back in 2010, but got no replies :(

          I would have thought it is supposed to be QProgressBar:indeterminate, no mention of ::chunk, (it applies the the QProgressBar as a whole), but I think you've both tried that.

          TobiasT Offline
          TobiasT Offline
          Tobias
          wrote on last edited by
          #3

          @JonB Thank you, I already tried this and did not work.

          1 Reply Last reply
          0
          • TobiasT Offline
            TobiasT Offline
            Tobias
            wrote on last edited by
            #4

            I found the solution:
            https://doc.qt.io/qt-5/stylesheet-customizing.html#box-model
            The bug in the current code was that that we tried to use margins instead of borders.

                  m_pProgressBar->setStyleSheet(QString::fromUtf8(R"(
                    QProgressBar {
                      border-image: url(:/images/launcher/ProgressBar_BG.png);
                      font-family: "Verdana";
                      font-size: 13px;
                      font-weight: bold;
                      color: #bfbfbf;
                      text-align: center;
                      border-top: 2px;
                      border-left: 2px;
                      border-bottom: 3px;
                      border-right: 3px;
                    }
                    QProgressBar::chunk {
                      border-image: url(:/images/launcher/ProgressBar.png);
                    }
                  )"));
            

            Setting the borders correct in the Style and not using margins in the ```Style::chunk```` solved the problem.

            1 Reply Last reply
            1

            • Login

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