[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt]
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2011-11-26 17:29:46
Message-ID: 35e29f837dc0e77a5e0066290e9a2ab2 () localhost
[Download RAW message or body]

On Sat, 26 Nov 2011 10:37:12 -0600, Jack Cosgrove <jackcosgrove@gmail.com>
wrote:
> Hi,
> 
> I'm trying to connect a C++ signal to a Python slot. What is the best
> way to do this?

Two ways...

1. Make the receiver visible to C++ and use QObject::connect(), ie.
decorate the slot with pyqtSlot().

2. Make the transmitter visible to Python and PyObject_Call() the signal
object, ie. convert the transmitter to a Python object. Note that this will
only work if there are .sip bindings for the transmitter.

> My current approach is to use sipQtAPI::qt_connect, and to do this I
> need to apparently convert the C++ object to a PyObject using SIP. I do
> that using sipAPIDef::api_get_pyobject. However whenever I call this
> method using the appropriate sipType I get a segmentation fault.

qt_connect() is internal, don't use it. sipGetPyObject() doesn't do what
you think it does - sipConvertFromType() is probably what you want.

> I have included a small qmake project that replicates this behavior.
> Could someone look it over and offer advice on what I am doing wrong?

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic