Thorfin
Thorfin

Reputation: 2012

QPluginLoader with PyQt modules as plugins: possible?

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

Upvotes: 1

Views: 2391

Answers (1)

Tamás
Tamás

Reputation: 48091

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.

Upvotes: 2

Related Questions