[PyQt] Hybrid C++ and Python in a Qt GUI

Phil Thompson phil at riverbankcomputing.com
Thu Nov 20 17:30:04 GMT 2014


On 20/11/2014 2:41 pm, Eric Frederich wrote:
> Hello,
> 
> We're starting a new project, no C++ code or Python code.
> In fact, we're porting a bunch of Tcl code.
> 
> Anyway, at the end of this project I'd like to have a Qt GUI where a
> developer can create a new tool for the application in either C++ or 
> Python.
> 
> My question:
> What is the best approach for something like this?
> 
> My assumption:
> Please don't dwell on this if it is completely wrong, just disregard it 
> and
> answer the above question.
> Assumption: the host should be PyQt since PyQt can integrate C++ 
> components
> via SIP but a C++/Qt application cannot easily integrate a PyQt 
> component.

Wrong assumption. Take a look at the Python API - there is nothing 
special about PyQt as far as it is concerned.

> Another assumption: My PyQt stuff would be able to connect to C++ 
> signals /
> Slots but my C++ stuff would not be able to connect to my Python 
> signals /
> slots.  Is this true?

No. Signals and slots defined in Python are added to the QMetaObject and 
so are accessible from C++ like any C++ signal or slot.

Phil


More information about the PyQt mailing list