Closed psobolewskiPhD closed 12 months ago
@Czaki also suggested:
it could be nice to add check if minimum is lower than maximum in setRange
So this is the case where someone does setRange(100, 0) or similar. In this case is it better to raise a ValueError or just swap min and max so they are correct?
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
b927159
) 87.45% compared to head (7d9223e
) 87.44%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Let's do what Qt does for it
https://doc.qt.io/qt-6/qabstractslider.html#setRange
If max is smaller than min, min becomes the only legal value.
update
Justed tested with QSlider and there seems to be no error, but the widget becomes invisible, I guess because min. and max become the same.
Swapping would be unexpected behavior so I suggest we either follow what Qt does, (puts min and max equal to min?) or raise a value error.
I would prefer the later, not sure what others think :)
I was also leaning towards ValueError.
Can then use with pytest.raises(ValueError):
to test.
Edit: but there is some value in mimicking Qt behavior, so totally open to implementing that too!
Yeah, I agree with mimicking qt behavior. It should just do the same thing that the regular QSpinBox does.
Closes https://github.com/pyapp-kit/superqt/issues/220
As suggested by Grzegorz here https://github.com/pyapp-kit/superqt/issues/220#issuecomment-1824785806 in this PR I have setMin and setMax check versus the current value and if that is smaller/larger it's reset to min/max.
I also added a test for the issue that fails on current main, but passes with this fix.