[PyQt] pyqt5qmlplugin

Phil Thompson phil at riverbankcomputing.com
Sun Nov 9 11:16:11 GMT 2014


On 09/11/2014 10:54 am, Marcus Ottosson wrote:
> Hi,
> 
> I’m attempting to write a Python plug-in for QML but are having issues 
> in
> getting it to work.
> 
>    -
> 
>    PyQt5 5.3.2/5.3.1
>     -
> 
>    Qt 5.3.2/5.3.1
>     -
> 
>    Python 2.7
>     -
> 
>    Ubuntu 12.04 and Windows 8
> 
> Running the Charts example produces the error:
> 
> ..extending/chapter6-plugins/app.qml:42 module "Charts" is not 
> installed
> 
> And writing my own does the same. In fact, I’m having trouble 
> understanding
> how the qmldir is able to provide enough information about which class 
> to
> use as subclass of QQmlExtensionPlugin.
> 
> Here’s the Charts qmldir file.
> 
> module Charts
> plugin pyqt5qmlplugin
> 
> I also tried modifying it to point to the directory with the 
> pyqt5qmlplugin
> library.
> 
> module Charts
> plugin `pyqt5qmlplugin` /home/marcus/Qt/5.3/gcc_64/plugins/PyQt5
> 
> If I understand correctly, the pyqt5qmlplugin library is looking for a
> Python module with the same name as the module, in this case Charts,
> suffixed with “plugin.py”, so “Chartsplugin.py” (is the upper-case 
> relevant
> here?) but when inside, how does it find the right class to use? Does 
> it
> need to start with the same name as the module (i.e. “Charts”) and end 
> with
> “Plugin”?
> 
> Is there any other examples of this in action? So far, this is the only
> mention of pyqt5qmlplugin I’ve been able to find.
> 
>    -
> 
> http://pyqt.sourceforge.net/Docs/PyQt5/qml.html#writing-python-plugins-for-qmlscene

It looks for a class that is derived from QQmlExtensionPlugin.

Phil


More information about the PyQt mailing list