[Solved] PyQt Signals
Hi,
When I put this piece of code in my PyQt python script:
It complains this error:
widget.connect(comboBox, QtCore.SIGNAL”), function(param))
TypeError: argument 3 of QObject.connect() has an invalid type
Is there any way I can have my function with parameters or is the only way:
Thanks!!
6 replies
The connect function expects a reference to a function, what you are doing is passing it the result of a function. The simple case is:
- comboBox.activated.connect(test)
If you want to pass a parameter to the slot function then you need to use a lambda as follows:
- comboBox.activated.connect(lambda: test(1))
If you want to pass a variable rather than a static value then:
- x=10
- comboBox.activated.connect(lambda: test(x))
You must log in to post a reply. Not a member yet? Register here!

