qt4 - Connect signal to function with many argument? -
i have function in python def:
def niveau(controlname,idniveau)
i want connect signal in way:
qobject.connect(dialog.findchild(qdialogbuttonbox, 'buttonbox'), signal('accepted()'),niveau(control,1))
i got following error:
qt signal not callable
can me this?
the error because qobject.connect
3 parameters means:
qobject.connect(qobject, signal(), callable, qt.connectiontype=qt.autoconnection)
the third parameter you're passing isn't callable, return value of call niveau(control,1)
.
the arguments signal emitted determined @ emit time, not @ connect time. if speicfy (or all) parameters @ connect time, can:
use
functools.partial
:from functools import partial qobject.connect(... , partial(niveau, control, 1))
use lambda
qobject.connect(... , lambda ctrl=control, id=1: niveau(ctrl, id))
edit:
by way, should use new style signals - old style signals will not supported anymore in pyqt5.
Comments
Post a Comment