[PyQt] pyqtSlot

oliver oliver.schoenborn at gmail.com
Thu Aug 25 13:36:15 BST 2016


If the slot weren't in the QMetaObject, how would the object method get
called (it does get called)? Also do you mean inspecting via Python (i.e.
with print or debugger) or do you mean at the c++ level (attaching to
process with VS)?

On Thu, Aug 25, 2016, 07:59 Phil Thompson <phil at riverbankcomputing.com>
wrote:

> On 25 Aug 2016, at 12:48 pm, oliver <oliver.schoenborn at gmail.com> wrote:
> >
> > I read recently in an exchange between Florian and Phil that:
> >
> > The main purpose of pyqtSlot is to define a new entry in the QObject's
> QMetaObject, so you would normally only use it on a method. pyqtSlot
> doesn't check that the containing class is a QObject because it might be
> being used as a mixin. When the connection is made the receiver must be a
> QObject.
> >
> >
> > In our code, we wrap slots so that we can customize error handling, so
> in a couple places we have code like this:
> >
> >
> > def slot_fixer(qobject_method):
> >
> >     def slot_wrapper():
> >
> >          ...do stuff...
> >
> >          qobject_method()
> >
> >     return pyqtSlot()(slot_wrapper)
> >
> >
> > class Foo(QObject):
> >
> >     def qobject_method(self):
> >
> >         ....
> >
> >
> >     slot_qobject_method = slot_fixer(qobject_method)
> >
> >
> > I.e., the method wrapped is from a QObject-derived class, but what
> pyqtSlot "decorates" is a wrapper for this method. This seems to have been
> working fine in PyQt 5.3 and 5.5, were we just lucky? Is it safe in 5.7?
>
> Inspect the QMetaObject to see if the slot is there as you would expect.
>
> Phil
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160825/0f01aad4/attachment.html>


More information about the PyQt mailing list