[Interest] Curious behaviour of slider/spin when controlled by keyboard

Joseph W Joshua joshua at panthertechno.com
Fri Nov 16 08:15:43 CET 2012


I am unable to reproduce this, I am using Qt 4.8.1, both on windows and
linux.


> Hello. I ran into a curious behaviour when writing a PyQt program but
later
> found out that it is not particular to PyQt but exists in C++/Qt as well.
> 
> I've attached minimal test cases. I note that in both the C++/PyQt minimal
> examples the bug is reproducible only when there is only a slider + a
> doubleSpin ("2-widgets") and not when there is also an integer spin ("3-
> widgets"). When there is an integer spin in addition ("3-widgets"), there
is
> some lagging behind between the widgets (as can be seen visually as well
as
> in the debug output) but it gets through and I'm able to run the whole
range
> using the keyboard, but if there is no integer spin and only the double
spin
> with the slider
> ("2-widgets") , the problem surfaces. It is clear this has something to do
with
> the limitations of floating point data type (but I'm surprised it would
surface
> even when only two decimal placesare involved).
> 
> I presume others would have encountered such situations and would like
> advice on how to work around this limitation.
> 
> The problem is as described below:
> 
> Steps:
> 1. Let the focus be either on the slider or the spin. (The default
slider/spin
> value is 0.50.) 3. Press up-arrow key to increase the slider/spin value.
> 
> Observation:
> The value will not increase past 0.56.
> 
> Steps:
> 4. Press down-arrow key to decrease the slider/spin value until 0.30.
> 5. Press down-arrow once more.
> 
> Observation:
> The value jumps down from 0.30 to 0.28 even though the precision is set at
> 0.01.
> 
> Step:
> 6. Press up-arrow.
> 
> Observation:
> The value will now not rise above 0.28.
> 
> Step:
> 7. Adjust the slider position using the mouse.
> 
> Observation:
> The value can change to any value in its full range from 0.00 to 1.00.
> 
> Step:
> 8. Adjust the slider using the mouse to go beyond 0.60.
> 9. Press down-arrow to decrease the value until 0.59.
> 10. Press down-arrow once more.
> 
> Observation:
> 11. The value jumps down to 0.56.
> 12. It will no longer go above 0.56 using the keyboard (as before).
> 
> --
> Shriramana Sharma





More information about the Interest mailing list