[PyQt] qcombobox SIGNAL issue

Baz Walter bazwal at ftml.net
Thu Jun 12 17:21:14 BST 2014


On 12/06/14 09:04, singhai.nish wrote:
> Although I should have seen the pyqt4 reference, which has it ( but just in
> rage wanting to get it solved had to put on forum, thank you for that
> answer)
>
> activated (const QString&)
> (http://pyqt.sourceforge.net/Docs/PyQt4/qcombobox.html#activated-2)
>
> It could be written as
>
> QObject.connect(self.comboBox SIGNAL('activated(QString)'), self.abcdef)
>
> 1. Why is there a different way writing the same thing

The old-style syntax which you use above is error-prone, verbose, and, 
from a python point of view, very ugly. It also requires some knowledge 
of C++, which not everyone has.

Probably the worst thing, though, is that it does not raise an error if 
you get the signal signature wrong, and so it is a very common 
hiding-place for bugs.

The new-style syntax provides a solution to all these problems:

     http://pyqt.sourceforge.net/Docs/PyQt4/new_style_signals_slots.html

(You should also be aware that the old-style syntax is only supported in 
PyQt4 - your example code above would not work at all in PyQt5).

-- 
Regards
Baz Walter


More information about the PyQt mailing list