Slider with detents?



  • I've got a request to have sliders with "detent" positions. Not sure if this is the best term, so here's the idea: say you have a slider that goes from -1 to 1, and you want the user to be able to reliably hit the "0" position, by making the slider knob/button "stick" somewhat to that middle point, as he is sliding close to that point.

    I don't see anything in the way of Qt API or stylesheets that can be used to make this work. Any clever ideas, short of writing a new slider subclass (or if someone has done that work, lemme know)?

    Thanks!



  • maybe you'd like to implement your own QYourSlider::mouseReleaseEvent() where you convert cursor position to slider value and if its value is within the range around your 'quantized' values, set slider position to it.

    _Edited: take a look "here":http://www.qtcentre.org/threads/9208-QSlider-step-customize also _



  • It might be easiest to just watch the valueChanged() event and if the value is within some epsilon of your "detent" position, manually set the value.



  • Thanks for the ideas!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.