Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
QProgressbar resets to -1
Megamouse last edited by Megamouse
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?
@Megamouse Is it possible that at some point
myBar->value() + delta
were bigger than what you set using setRange()?
@jsulm actually from what I remember, set range does not change the current value.
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?
@J.Hilk I mean other way around: you set max to 10 and then setValue(11) - not sure what will happen.
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 ...