简体   繁体   中英

How can I avoid wrap-around in the QDial control?

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

要避免的行为动画

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

Is that possible at all?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM