[C++-sig] Best way to use python as an API inside a Qt/C++ app?

Stefan Seefeld seefeld at sympatico.ca
Thu Apr 27 02:20:50 CEST 2006


craig harris wrote:
> I am using Qt as the GUI for a C++ app.  I would also like to use python 
> as an API for the application.  For instance when a menu item is 
> pressed, a stored python command is executed.
> 
> Is this wise?

That sounds very reasonable to me.

> And what is the best approach (tool) to implementing 
> this?  PyQt, boost.python, other?

That depends on what you mean by 'implement'. Executing some
python code via a menu is trivial. What is much less trivial is
to expose your application's state to python so you can access
and modify it from these commands. As far as Qt is concerned, there
already are a number of bindings (sip for Qt3, and boost.python for
Qt4). How to reflect your own code into python is a different issue.
Boost.python is definitely a good choice, though if you use a lot of
Qt internally it would be best to stay with the tool used to generate
the Qt bindings, and simply add your own classes.

Regards,
		Stefan




More information about the Cplusplus-sig mailing list