PyQt QSpinBox update range depending on the value of other spinbox

后端 未结 1 1432
渐次进展
渐次进展 2021-01-16 07:54

i am using pyqt4 to develop a GUI for the first time;

I have a spinbox, and I would like the range of values allowed in it to be dependant on the value another spin

相关标签:
1条回答
  • 2021-01-16 08:34

    You have not shown your code where you make the connection between the 'valueChanged' signal of spinbox2 with the function. Are you making that connection ?. Also the code you have given for function seems to be incomplete.

    You can try something like this:

    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)
    
    0 讨论(0)
提交回复
热议问题