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 has rendering errors or does not render at all
Qt 6.11 is out! See what's new in the release blog

QProgressBar has rendering errors or does not render at all

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++qt6
19 Posts 6 Posters 5.2k Views 2 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.
  • Y YuXin

    @JonB The timing of the startTimer does not affect the issue. Regardless of how it is adjusted, the problem can still be reproduced. Even if it is increased tenfold to 500, the issue persists—it's just that a shorter interval allows the problem to occur more quickly.

    Additionally, the purpose of this  if  statement is exactly as you assumed: to randomly trigger  setValue , rather than being aligned with the 50-interval setting.

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

    @YuXin said in QProgressBar has rendering errors or does not render at all:

    The timing of the startTimer does not affect the issue.

    In principle an odd number is more likely to trigger QDateTime::currentMSecsSinceEpoch() % 2 being true on alternates than always being either true or false.

    the purpose of this if statement is exactly as you assumed: to randomly trigger setValue

    Exactly. And for that you would be much better off using a random number than your potentially-deterministic QDateTime::currentMSecsSinceEpoch() % 2 .

    Anyway, I am sorry if we digressed. I intended this to be a brief comment, especially for posting for others to reproduce.

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

      Hi,

      Which version of Qt are you using ?
      On which OS ?

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

      Y 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Which version of Qt are you using ?
        On which OS ?

        Y Offline
        Y Offline
        YuXin
        wrote on last edited by YuXin
        #8

        @SGaist This question has been answered in the page.

        SGaistS 1 Reply Last reply
        0
        • Y YuXin

          @SGaist This question has been answered in the page.

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #9

          @YuXin Sorry, I missed that line.

          Could you test with a more recent version of Qt ?

          One small note: you are using a pretty large range which means that you won't necessarily see the painting done immediately. While it's likely unrelated to the issue at hand, it adds an unnecessary delay to test your issue.

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

          Y 1 Reply Last reply
          0
          • SGaistS SGaist

            @YuXin Sorry, I missed that line.

            Could you test with a more recent version of Qt ?

            One small note: you are using a pretty large range which means that you won't necessarily see the painting done immediately. While it's likely unrelated to the issue at hand, it adds an unnecessary delay to test your issue.

            Y Offline
            Y Offline
            YuXin
            wrote on last edited by
            #10

            @SGaist The fact that the same issue occurred during the testing of version 6.9.0 clearly indicates that upgrading the version is useless. I also tested the currently latest version, 6.10, and the result is that the same problem persists.

            SGaistS 1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #11

              Hi, it seems you have a race condition, i.e. the graphics effect and the progress bar are fighting each other, and currently the graphics effect is winning.

              Try giving the progress bar the upper hand by telling it to repaint, say like this:

              ...
              // add a repaint call
              void timerEvent(QTimerEvent* event) override {
                      if (QDateTime::currentMSecsSinceEpoch() % 2)
                      {
                          pb.setValue(pb.value() + 1);//If the number 1 is changed to a number greater than or equal to 20, it will work normally
                          pb.repaint();
                      }
                      static int counter = 1;
                      text.setText(QString::number(counter++));
              }
              ...
              
              Y 2 Replies Last reply
              0
              • Y YuXin

                @SGaist The fact that the same issue occurred during the testing of version 6.9.0 clearly indicates that upgrading the version is useless. I also tested the currently latest version, 6.10, and the result is that the same problem persists.

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #12

                @YuXin said in QProgressBar has rendering errors or does not render at all:

                @SGaist The fact that the same issue occurred during the testing of version 6.9.0 clearly indicates that upgrading the version is useless. I also tested the currently latest version, 6.10, and the result is that the same problem persists.

                No, it only indicates that there's an issue with the version you tested against.

                Since it still happens with 6.10, then there's indeed something to investigate.

                Try the suggestion of @hskoglund and if does not improve the situation, then check the bug report system and if you don't find anything there, please open a new ticket providing your minimal example with the adjustments people suggested on this thread.

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

                Y 1 Reply Last reply
                0
                • SGaistS SGaist

                  @YuXin said in QProgressBar has rendering errors or does not render at all:

                  @SGaist The fact that the same issue occurred during the testing of version 6.9.0 clearly indicates that upgrading the version is useless. I also tested the currently latest version, 6.10, and the result is that the same problem persists.

                  No, it only indicates that there's an issue with the version you tested against.

                  Since it still happens with 6.10, then there's indeed something to investigate.

                  Try the suggestion of @hskoglund and if does not improve the situation, then check the bug report system and if you don't find anything there, please open a new ticket providing your minimal example with the adjustments people suggested on this thread.

                  Y Offline
                  Y Offline
                  YuXin
                  wrote on last edited by
                  #13

                  @SGaist that's ok

                  1 Reply Last reply
                  0
                  • hskoglundH hskoglund

                    Hi, it seems you have a race condition, i.e. the graphics effect and the progress bar are fighting each other, and currently the graphics effect is winning.

                    Try giving the progress bar the upper hand by telling it to repaint, say like this:

                    ...
                    // add a repaint call
                    void timerEvent(QTimerEvent* event) override {
                            if (QDateTime::currentMSecsSinceEpoch() % 2)
                            {
                                pb.setValue(pb.value() + 1);//If the number 1 is changed to a number greater than or equal to 20, it will work normally
                                pb.repaint();
                            }
                            static int counter = 1;
                            text.setText(QString::number(counter++));
                    }
                    ...
                    
                    Y Offline
                    Y Offline
                    YuXin
                    wrote on last edited by
                    #14

                    @hskoglund First of all, I sincerely apologize for the delayed reply—I’ve been extremely busy.

                    Secondly, your proposal is indeed feasible, but I’d like to know what you mean by "race condition"—I’ve never heard of it before.

                    Is there any documentation that explains this?

                    jsulmJ 1 Reply Last reply
                    0
                    • Y YuXin

                      @hskoglund First of all, I sincerely apologize for the delayed reply—I’ve been extremely busy.

                      Secondly, your proposal is indeed feasible, but I’d like to know what you mean by "race condition"—I’ve never heard of it before.

                      Is there any documentation that explains this?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #15

                      @YuXin https://en.wikipedia.org/wiki/Race_condition

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • hskoglundH hskoglund

                        Hi, it seems you have a race condition, i.e. the graphics effect and the progress bar are fighting each other, and currently the graphics effect is winning.

                        Try giving the progress bar the upper hand by telling it to repaint, say like this:

                        ...
                        // add a repaint call
                        void timerEvent(QTimerEvent* event) override {
                                if (QDateTime::currentMSecsSinceEpoch() % 2)
                                {
                                    pb.setValue(pb.value() + 1);//If the number 1 is changed to a number greater than or equal to 20, it will work normally
                                    pb.repaint();
                                }
                                static int counter = 1;
                                text.setText(QString::number(counter++));
                        }
                        ...
                        
                        Y Offline
                        Y Offline
                        YuXin
                        wrote on last edited by YuXin
                        #16

                        @hskoglund I looked into it: when changing the progress bar value, it internally calls
                        repaint, which should trigger an immediate redraw.

                        On the other hand, the label uses
                        update, but the call to
                        update shouldn’t be executed until the
                        repaint is completed. Moreover, by the time this timer event starts, the previous drawing of the label should already have been completed.

                        Why would there be a race condition in this scenario?

                        1 Reply Last reply
                        0
                        • Christian EhrlicherC Offline
                          Christian EhrlicherC Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on last edited by
                          #17

                          There is no race condition but you use QGraphicsDropShadowEffect for a child widget with a radius of 10 so this widget is responsible for drawing everything of it's size + 10 pixel which overlaps with your progressbar.
                          I don't understand why you use QGraphicsDropShadowEffect with this large radius at all. What do you want to achieve for a plain QWidget not in a QGraphicsScene?

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          Y 1 Reply Last reply
                          0
                          • Christian EhrlicherC Christian Ehrlicher

                            There is no race condition but you use QGraphicsDropShadowEffect for a child widget with a radius of 10 so this widget is responsible for drawing everything of it's size + 10 pixel which overlaps with your progressbar.
                            I don't understand why you use QGraphicsDropShadowEffect with this large radius at all. What do you want to achieve for a plain QWidget not in a QGraphicsScene?

                            Y Offline
                            Y Offline
                            YuXin
                            wrote on last edited by
                            #18

                            @Christian-Ehrlicher I also think there is no race condition here, but can you tell me why their overlapping drawing areas would cause this? I'm really curious about the reason, even though I already know the solution.

                            1 Reply Last reply
                            0
                            • Christian EhrlicherC Offline
                              Christian EhrlicherC Offline
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on last edited by
                              #19

                              As I said - the effect draws outside it's client area.

                              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                              Visit the Qt Academy at https://academy.qt.io/catalog

                              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