I would like to subclass QDial, because when you're at min value, you can change value to max easily (by going down). Same problem from max to min.
In order to do that, I know I have to subclass QDial. But I don't know where to start.
I would like to subclass QDial, because when you're at min value, you can change value to max easily (by going down). Same problem from max to min.
In order to do that, I know I have to subclass QDial. But I don't know where to start.
I may provide some guidance to you... let's try.
First of all you should start with QDial
, not QAbstractSlider
, because the target methods you should reimplement are
virtual void mouseMoveEvent(QMouseEvent *e)
virtual void mousePressEvent(QMouseEvent *e)
virtual void mouseReleaseEvent(QMouseEvent *e)
which handle mouse actions like the names state. Looking at the source you can see, that the methods of question simply try to map the cursor position to a valid dial position. Here the 'jump' happens, which you want to disable (I tried several control keys (page up/down, arrow up/down, mouse wheel and mouse click/drag) and only by clicking you may skip an undefined amount of values.). Additionally you may want to set pageStep
to a value you application supports.
As a solution I may propose that you take the result of the valueFromPoint
method and decrement or increment (if the value is lesser or bigger) the current value instead of setting it to the result. This should disable jumps.
Qt 5.6.0
I came across this question looking for information about how to change some of the dial properties. You can stop the slider on the dial moving from min to max "quickly" (jumping across) by using the setWrapping(bool)
slot.
myNewDial = new QDial(whateverYourQWidgetIs);
myNewDial->setWrapping(true);
This will give you the full 360 degree range of motion of the slider.