gpt4 book ai didi

python - PyQt QSpinBox 更新范围取决于其他 spinbox 的值

转载 作者:行者123 更新时间:2023-11-30 23:53:22 26 4
gpt4 key购买 nike

我第一次使用pyqt4开发GUI;

我有一个旋转框,我希望其中允许的值范围取决于另一个旋转框的值。例如,第一个旋转框中允许的最大值应等于第二个旋转框中的值。

我认为使用 valueChanged() 信号来调用类似以下的方法是可能的:

def function
max = spinbox2.value()
spinbox1.setMaximum(max)

但这不起作用,有人知道该怎么做吗?

谢谢

最佳答案

您尚未显示在 spinbox2 的“valueChanged”信号与函数之间建立连接的代码。你正在建立这种联系吗?此外,您为 function 提供的代码似乎不完整。

你可以尝试这样的事情:

spinbbox2.valueChanged.connect(handler)
# Or this which works for Python 3.5
spinbbox2.valueChanged[int].connect(handler)

# The function handler called is called whenever
# value in spinbox2 is changed and parameter to
# handler is the new value of spinbox2
def handler(value):
spinbox1.setMaximum(value)

关于python - PyQt QSpinBox 更新范围取决于其他 spinbox 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5777885/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com