[PyQt] simpler 'connect' function
Ewald de Wit
erdewit at zonnet.nl
Thu Jan 17 22:35:16 GMT 2008
On Thursday 17 January 2008 18:27:19 Peter Shinners wrote:
> > button.clicked.connect(self.onButtonClicked)
> Is there a clean way to handle signals with the same name that take
> different arguments? Here's an idea I can think of for QComboBox.
A simpler way would be to just give the signal objects a different name,
like activatedInt and activatedString. It's the easiest way to uniquely
specify which signal you mean.
Btw, it would also be convenient to have an emit method on the signal
object, like for example
If __call__ is used instead of emit, then the syntax becomes even shorter:
And once there is a signal object, other methods become possible as well.
For example a slots() method that returns a list of all connected
slots. One could then do lazy evaluation like
result = self.doHeavyJob()
This example skips doing the heavy job if there is no one listening for
the result. Just some ideas.
More information about the PyQt