[PyQt] Slot connections fail with newest snapshot

Phil Thompson phil at riverbankcomputing.com
Sun Jul 17 12:57:24 BST 2016

On 17 Jul 2016, at 11:09 am, Florian Bruhin <me at the-compiler.org> wrote:
> * Phil Thompson <phil at riverbankcomputing.com> [2016-07-16 17:10:55 +0100]:
>> On 14 Jul 2016, at 10:32 am, Florian Bruhin <me at the-compiler.org> wrote:
>>> Hi,
>>> I just tried PyQt5_gpl-5.7.dev1607121154 and sip-4.18.1.dev1607032332
>>> (with a debug Python build FWIW), and with the attached code I get:
>>>   QObject::connect: Cannot connect QCoreApplication::aboutToQuit() to (null)::lot()
>>>   Traceback (most recent call last):
>>>     File "foo.py", line 13, in <module>
>>>       app.aboutToQuit.connect(obj.slot)
>>>   TypeError: connect() failed between aboutToQuit() and lot()
>>> It looks like there's a off-by-one error somewhere, as the method is
>>> called "slot", not "lot"?
>>> I noticed it doesn't happen without @pyqtSlot, and it also doesn't
>>> happen with a function instead of a method.
>> The current behaviour is different, but what are you expecting to
>> happen (given your class does not inherit from QObject)?
> Oh, @pyqtSlot only works on classes inheriting from QObject? While
> that makes some sense, that's news for me!
> I think either it should just be ignored (like before?), or show some
> useful error message like "pyqtSlot can only be used on classes
> inheriting from QObject" or so. I also think this should be pointed
> out in the docs for @pyqtSlot - while the examples do inherit from
> QObject, it's not explicitly documented anywhere I think.

You can use it in classes that are used as mixins with QObject derived classes.


More information about the PyQt mailing list