将 QComboBox 或 QSpinBox 设置为不允许的值

发布于 2024-08-12 04:03:02 字数 217 浏览 4 评论 0原文

我正在维护一个应用程序,它试图帮助用户让他的参数一起工作,因为存在许多相互依赖关系。

现在变量 Y 有一个默认值 x。当用户更改其他某个变量 Z 时,Y 可能会出现一个大于 x 的新最小值。这被设置为旋转框的最小值。现在旋转框不能再显示当前值,而是显示最小值。我希望用户能够看到他以前的价值。是否有一些我在 Qt 中看不到的设置来实现这样的目标?

同样的问题也适用于 QComboBox。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲世九天 2024-08-19 04:03:02

作为一种方法,您可以创建新类,继承自 Qt 标准 QSpinBox(或者在第二种情况下继承自 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.

找个人就嫁了吧 2024-08-19 04:03:02

另一种方法是将每个小部件连接到函数,该函数将检查其他值是否正确(如果不正确,则会更正它们):)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文