3

I have a QDial control, and I want/need to block the jump or wrap-around between the minimum and maximum values.

animation of the behavior to avoid

I can not find anything in the documentation nor the properties.

Is that possible at all?

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • Technically it doesn't overflow. Anyway, you will most likely have to roll out your own control or override the existing in order to get the behavior you need, that's a common problem with Qt controls. – dtech Apr 10 '17 at 11:00
  • the problem is that I dont want to spring so hard from 99 to 0, since that should be later a hardware signal that is not going to change as drastically as in the gui... – Firewall-Alien Apr 10 '17 at 11:04
  • You do not have to create a special control for this, read my post below. – Aeonos Apr 10 '17 at 11:21

2 Answers2

1

It is not an overflow. The QDial follows the position of the cursor, regardless of where it went, so when the cursor is near 0, the value is set to 0 regardless of the previous value.

If you want to change this behavior you will have to create your own widget (it can be based on QDial either by inheritance or composition) where you also keep track of where the mouse went to force the user to go through all values in order.

Also you said the issue is that you have a steep change in value and that the value is latter use in hardware. In this case you should have a kind of controller class between the GUI and the hardware that ensure that values are correct for the hardware.

Benjamin T
  • 8,120
  • 20
  • 37
-1

In the QDial properties, go to QDial group and enable 'wrapping', that will solve your problem :)

The value than continous. Below 0 will be -1, -2 ,... and above your max it will also just go on. So you will have to calculate the real value using modulo, but that is by far easier and faster than creating a new control.

Aeonos
  • 365
  • 1
  • 13
  • It does not work. If the user is at 99 and goes higher, the value will be 100; Then you apply `%` and end up with 0. Moreover wrapping does not work as you said, values are still bounded between 0 and 99 anyway. It gets even worse because it allows the user to go from 0 to 99 and back with the mouse wheel, which is not possible without wrapping. – Benjamin T Apr 10 '17 at 12:09