[PyQt] Hybrid C++ and Python in a Qt GUI
Mathias.Born at gmx.de
Mathias.Born at gmx.de
Thu Nov 20 22:30:56 GMT 2014
On 20.11.2014, 15:41:10 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.
I'm doing exactly that. I embedd the Python interpreter and PyQt into the application.
All the stuff which the application exposes to Python is exposed as modules via SIP.
Finally, there is a module written in Python which is imported by the application
when it starts, calling a specific function which must be defined in that module.
That's the hook from where anything can be done in Python, depending on how much
functionality the application exposes.
Also, I have additional Python modules which implement functionality literally
outsourced into Python, to make the application customizable.
For that purpose, I build the Python interpreter and PyQt myself.
In addition, I use boost::python to access Python onjects, because that's much more
comfortable than using the C-API.
Best Regards,
Mathias
More information about the PyQt
mailing list