Qt Forum

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

    Unsolved QProgressbar resets to -1

    General and Desktop
    3
    5
    414
    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.
    • Megamouse
      Megamouse last edited by Megamouse

      Hi,

      I was wondering why our progressbars in the dialogs never reached the maximum.
      The backend only increased the value by a delta, which was then handled in the dialog with something like:

      myBar->SetValue(myBar->value() + delta);
      

      As it turned out the Progressbar initializes with value = -1.
      Why is that?

      best,
      Megamouse

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @Megamouse last edited by

        @Megamouse Is it possible that at some point

        myBar->value() + delta
        

        were bigger than what you set using setRange()?

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

        J.Hilk 1 Reply Last reply Reply Quote 1
        • J.Hilk
          J.Hilk Moderators @jsulm last edited by

          @jsulm actually from what I remember, set range does not change the current value.

          e.g
          value == 20 -> setRange(0,10) -> value still at 20

          I don't know why its done, but creating a QProgressBar or calling reset() on an existing one will set the current value to -1;

          I would assume that this is done, to allow the valueChanged() signal to be emitted when the value is set to 0?

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

          Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          jsulm 1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @J.Hilk last edited by

            @J.Hilk I mean other way around: you set max to 10 and then setValue(11) - not sure what will happen.

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

            1 Reply Last reply Reply Quote 0
            • Megamouse
              Megamouse last edited by

              @jsulm no the value wasn't exceeding the max. (but that was another issue later as you can read below)

              I think this whole implementation is simply weird.

              as J.Hilk said: the reset and init of any progressbar/dialog set the value to minimum-1 (apart from the QWinTaskBarProgress).

              Also apart from that... any increase/decrease above/below the min and max just returns without doing anything.....
              I think that is just wrong. the progressbar should always increase until max is reached. There is no logical explanation for this choice of implementation ...

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