ttttcrngyblflpp
ttttcrngyblflpp

Reputation: 143

PySide Signal with Argument

QGroupBox has the signal clicked which has an optional checked parameter. Suppose I'm trying to connect a slot to it inside of some class like so: box.clicked.connect(self.func), so the declaration of the slot must be def func(self, checked), but func is being called with only one argument. How do I get the desired behaviour of func being called with both self and the optional checked arguments?

Upvotes: 0

Views: 695

Answers (1)

ekhumoro
ekhumoro

Reputation: 120798

The behaviour of signals with optional default parameters differs between PyQt and PySide. In PyQt, the default parameter is always sent, but in PySide you have to explicitly request it:

    box.clicked[bool].connect(self.func)

This is a much better design choice, I would say, as the PyQt behaviour can often lead to bugs if you forget that a default value will be sent even though you didn't ask for it. A case of explicit being better than implicit...

Upvotes: 1

Related Questions