[PyQt] SIP_ANYSLOT vs SIP_SLOT vs SIP_SLOT_CON()

Sébastien Sablé sable at users.sourceforge.net
Fri Sep 13 09:07:38 BST 2013


2013/9/10 Phil Thompson <phil at riverbankcomputing.com>
>
>
> That doesn't sound like a great design...

I agree but it is not my call. It may change when the code gets migrated to Qt5.

> SIP_SLOT just checks that the argument has been created by QtCore.SLOT(),
> ie. that it is a string that begins with the magic character. Plenty of
> examples in PyQt4.

Thanks for the explanations.
So I decided to start simple and go for SIP_SLOT for the moment. The
sip code I have looks like the following:

namespace Foo
{
namespace Bar
{
class PointsCloud
{
...
            void connect(const int eventType, QObject *, SIP_SLOT member);
%MethodCode
                sipCpp->connect(a0, a1, a2);
%End
...
}
}
}

The Python code looks like this:

class Starfield(QObject):
        def run(self):
                 self.cloud = Foo.Bar.PointsCloud()

self.cloud.connect(Foo.Bar.DomainOjbect.DomainObjectErased, self,
QtCore.SLOT('onCloudErased(Foo::Bar::DomainObjectErasedArgs)'))
                 self.cloud.erase()

        @pyqtSlot('Foo::Bar::DomainObjectErasedArgs')
        def onCloudErased(self, args):
                print "called"


In the end it works but I can't pass Python callables directly.
To have that, I would need to know the signature for the signal to
pass it to sipConnectRx, but I cannot get that.

Best regards

Sebastien


More information about the PyQt mailing list