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

Vincent Vande Vyvre vincent.vandevyvre at swing.be
Mon Oct 1 07:07:32 BST 2012


Le 01/10/12 06:02, Shriramana Sharma a écrit :
> Hello. With my work on a simple Cubic Bezier investigation application
> in PyQt (attached, obviously under GPL), I ran into a curious
> behaviour of the slider/spin (for the time along the curve) when
> controlled by the keyboard.
>
> Steps:
> 1. Let the focus be either on the slider (on the left) or the spin
> (below it). (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).
>
> Query:
> My sliderMoved, spinChanged slots are straightforward, and just
> convert the integer slider value to the spin and update the bezier
> widget accordingly. In which case, I do not understand what it is I am
> doing wrong in my programming. However, I wrote a minimal test where
> the behaviour is not seen. Any guidance is appreciated.
>
> Thanks!
>
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Seems an integer division question.

Change:
    self.dblSpin.setValue(scaledTime/100)
to:
    self.dblSpin.setValue(scaledTime/100.0)

and that's works

-- 
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>


More information about the PyQt mailing list