[PyQt] Proposal for New-style Signals

Phil Thompson phil at riverbankcomputing.com
Thu Jan 24 14:07:51 GMT 2008

On Thursday 24 January 2008, Andy Davidoff wrote:
> On Jan 24, 2008, at 5:27 AM, Phil Thompson wrote:
> > The design guarantees no future compatibility problems. What do you
> > mean
> > by "could create/hide bugs"?
> >
> >> Although I don't use an IDE or code completion, I would still
> >> prefer a
> >> more explicit type string over an implicit one.  I'd rather the code
> >> was more legible and I believe it could even help the developer catch
> >> type errors earlier, especially when working with someone else's
> >> code.
> It's not explicitly clear where the error is in the code below, or
> even if there is an error, since I have no idea which type list is the
> default...
> 	def slot(combovalue):
> 		if somedict.has_key(combovalue):
> 			print "You selected the value", combovalue
> 		else:
> 			print "Validation error!"
> 	q = QComboBox()
> 	q.currentIndexChanged.connect(slot)

You find out the same way you found out that there was a currentIndexChanged() 
signal in the first place - the docs.

> > Of the overloaded signals, none of the overloads are obvious
> > candidates for
> > being the default - so in those cases there would be no default and
> > the long
> > form would have to be used. In fact the only use of the "default"
> > flag would
> > probably be to preserve backwards compatibility in the event of a
> > later
> > version of Qt introducing a new overload.
> Which of the overloaded currentIndexChanged, activated, or highlighted
> signals on QComboBox, for example, are obviously not candidates for
> being the default?

They are all candidates for being the default, that's my point. There is no 
outstanding candidate.

> Honestly, the fact that the default is not guaranteed to always be
> usable sounds worse.
> Will there be any way to discover the default and/or exposed signals
> via reflection?

The following, slightly strange, code would work...

    for s in QComboBox.currentIndexChanged:
        if s is QComboBox.currentIndexChanged:
            print s, "is the default"


More information about the PyQt mailing list