我想在单击按钮时将参数传递给函数.我应该在这一行添加什么,button.connect(button, QtCore.SIGNAL('clicked()'), calluser(name))以便将值传递给函数:
def calluser(name):
print name
def Qbutton():
button = QtGui.QPushButton("button",widget)
name = "user"
button.setGeometry(100,100, 60, 35)
button.connect(button, QtCore.SIGNAL('clicked()'), calluser(name))
Run Code Online (Sandbox Code Playgroud)
还有一件事,按钮将使用for循环生成; 所以name价值会有所不同.所以我想用按钮附上每个名字.我在Pytk中做了同样的事情,使用for循环并在单击时调用参数基函数.