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

Phil Thompson phil at riverbankcomputing.com
Thu Nov 20 22:03:54 GMT 2014


On 20/11/2014 8:38 pm, Eric Frederich wrote:
> On Thu, Nov 20, 2014 at 12:30 PM, Phil Thompson 
> <phil at riverbankcomputing.com
>> wrote:
> 
>> 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.
> 
> 
> So there is a way, from a PyObject*, to get a usable instance of a 
> QObject
> that I could use from C++?

For that you use the SIP API...

http://pyqt.sourceforge.net/Docs/sip4/embedding.html

Phil


More information about the PyQt mailing list