views:

116

answers:

1

Hi!

I have a C++ application that loads externals plugins thanks to QPluginloader.
QPluginLoader provides access to a Qt plugin. A Qt plugin is stored in a shared library (a DLL).

The plugins have to inherit from a pure virtual class ( and Q_DECLARE_INTERFACE ) and QObject.

I would like to create plugins by using python and PyQt.
Is this possible without too much work?
For instance if I have to convert the modules to C++ with boost::python, this could be nonsense, as PyQt is already a conversion from C++ to Python...

Thanks!

Edit:
I have looked into the doc of pyqt regarding plugins:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#writing-qt-designer-plugins

PyQT has a specific class QPyDesignerCustomWidgetPlugin for qt designer plugins.
But this class is in the QtDesigner.pyd module, so I can not see the code in order to replicate the same architecture.

Edit2:
http://www.boddie.org.uk/david/Projects/Python/Qt/
File pyqt4-embedded-examples-2008-02-13.tar.gz
Contains code sample to integrate PyQt Widget in C++. But you don't use QPluginLoader and have to integrate the python interpretor headers in your C++ main code.

Thanks again

+2  A: 

Well, I don't think it's possible without too much work. If you write a module in PyQt, chances are that you would have to add the entire Python interpreter to your executable in order to be able to interpret those modules. Even if you translate those modules into C++, the translated functions will have to call the Python API at some point, thus introducing a dependency on Python itself.

Tamás
Indeed, I have seen pythonplugin.dll PyQt4\plugins\designer means there is a way to integrate python code as a designer plugin. But I don't know. Thanks
Thorfin
`pythonplugin.dll` is part of PyQt4, not Qt4. Indeed, it allows you to use Python-based plugins in Qt Designer, but it also calls back to Python in order to interpret those modules. If you load `pythonplugin.dll` into Dependency Walker (see http://www.dependencywalker.com/), you will see that it depends on Python.
Tamás