[PyQt] sip: Passing C++ QObject subclass as signal argument

Phil Thompson phil at riverbankcomputing.com
Sun Sep 10 10:13:27 BST 2017


On 10 Sep 2017, at 1:03 am, Patrick Stinson <patrickkidd at gmail.com> wrote:
> 
> Hello!
> 
> I have two custom QObject subclasses implemented in C++. I want to pass one of them (FDDocument) as an argument when I emit a signal from the other one (CUtil::fileOpened(FDDocument *)).
> 
> Right now the signal is emitted in python but I get a QObject pointer that hasn’t been converted to an FDDocument pointer. Here is my sip code:
> 
> 
> 
> %Module _cutil
> %Import QtGui/QtGuimod.sip
> 
> %ModuleHeaderCode
> #include "../_cutil.h"
> %End
> 
> 
> class FDDocument : QObject {
> private:
>     FDDocument();
> public:
>     QByteArray diagramData() const;
>     void updateDiagramData(const QByteArray *);
> };
> 
> class CUtil : QObject {
> private:
>     CUtil();
> public:
> 
>     static CUtil *instance();
>     
> signals:
>     void fileOpened(FDDocument *);
> };

Have you defined any %ConvertToSubClassCode for your class?

Phil


More information about the PyQt mailing list