[PyQt] simpler 'connect' function
phil at riverbankcomputing.co.uk
Thu Jan 10 17:59:40 GMT 2008
On Thursday 10 January 2008, Peter Shinners wrote:
> I'm sure this has come up, but as I write my Pyqt code, I keep noticing
> that the QObject.connect call feels like a wart. Is there already a pyqt
> shortcut for a call like this?
> QtCore.QObject.connect(myButton, QtCore.SIGNAL("clicked()"),
> The closer I could be to something like the following, the better.
> myButton.connect("clicked()", onClicked)
> Are there any shortcuts for wiring signals and slots I haven't noticed?
No, but a few ideas have been thrown around on the list in the past couple of
Your suggestion is nice and concise - the dropping of SIGNAL() was briefly
discussed during developed of PyQt4.
One sublety of your suggestion is that "self" provides the emitter object
whereas the short form of the Qt connect uses "this" to provide the slot
object. I don't know if that would be counter-intuitive.
I'd like people to continue to throw out suggestions and see if any sort of
concensus appears. The existing method for making connections will be
retained no matter what.
More information about the PyQt