简体   繁体   English

如何避免QDial控件中的回绕?

[英]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. 我有一个QDial控件,并且我希望/需要阻止最小值和最大值之间的跳转或环绕。

要避免的行为动画

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. QDial随光标的位置而定,无论它走到哪里,因此当光标接近0时,无论先前的值如何,该值都将设置为0。

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. 如果要更改此行为,则必须创建自己的窗口小部件(可以通过继承或组合基于QDial),在该窗口小部件中还要跟踪鼠标移动到的位置,以强制用户按顺序浏览所有值。

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. 在这种情况下,您应该在GUI和硬件之间具有一种控制器类,以确保该值对于硬件而言是正确的。

In the QDial properties, go to QDial group and enable 'wrapping', that will solve your problem :) 在QDial属性中,转到QDial组并启用“包装”,这将解决您的问题:)

The value than continous. 该值比连续。 Below 0 will be -1, -2 ,... and above your max it will also just go on. 低于0的是-1,-2,...,高于最大值的也将继续。 So you will have to calculate the real value using modulo, but that is by far easier and faster than creating a new control. 因此,您将必须使用模来计算实际值,但这远比创建新控件容易和快捷。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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