Python 为QcomboBox中的更改分配一个函数
我尝试在QcomboBox中发生更改时调用函数。更改组合框后,它将更新图形上的xAxis。当从组合框中选择不同的项时,是否有方法调用函数Python 为QcomboBox中的更改分配一个函数,python,user-interface,pyqt,Python,User Interface,Pyqt,我尝试在QcomboBox中发生更改时调用函数。更改组合框后,它将更新图形上的xAxis。当从组合框中选择不同的项时,是否有方法调用函数 def updateGraph(): print("update graph") proxy = QtGui.QGraphicsProxyWidget() xAxis = QtGui.QComboBox() proxy.setWidget(xAxis) xAxis.currentIndexChanged().connect(updateGraph)
def updateGraph():
print("update graph")
proxy = QtGui.QGraphicsProxyWidget()
xAxis = QtGui.QComboBox()
proxy.setWidget(xAxis)
xAxis.currentIndexChanged().connect(updateGraph)
当前产生的错误:
TypeError: native Qt signal is not callable
换线
xAxis.currentIndexChanged().connect(updateGraph)
到
使用currentIndexChanged
前面的括号,当您确实想要访问信号的connect
方法时,您实际上正在调用信号
xAxis.currentIndexChanged.connect(updateGraph)