开发者

Set a QComboBox or QSpinBox to a value not allowed

I am maintaining an application which tries to help the user get his parameters to work together, as there are many interdependencies.

Now there is a default value of x for a variable Y. When the user changes some other variable Z, there might be a new minimum value for Y which is greater than x. This is set as a minimum for the spinbox. Now the spinbox can not 开发者_高级运维display the current value anymore, but rather displays the minimum. I would like the user to be able to see his old value. Is there some setting I don't see in Qt to achieve something like this?

Same question goes for QComboBox.


As one approach you may create new class, inherited from Qt standart QSpinBox(or in second case from QComboBox) and add your own logic to them: posibility to show value below the minimum, but when someone want explicitly change value in your input widgets, you will check for bounds.


Another approach is to connect each widget to function that will check if others values are correct (and if not will correct them) :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜