<div dir="ltr"><div class="markdown-here-wrapper" style><p style="margin:1.2em 0px!important">Hi,</p>
<p style="margin:1.2em 0px!important">I’m attempting to write a Python plug-in for QML but are having issues in getting it to work.</p>
<ul style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px"><p style="margin:1.2em 0px!important;margin:0.5em 0px!important">PyQt5 5.3.2/5.3.1</p>
</li>
<li style="margin:0.5em 0px"><p style="margin:1.2em 0px!important;margin:0.5em 0px!important">Qt 5.3.2/5.3.1</p>
</li>
<li style="margin:0.5em 0px"><p style="margin:1.2em 0px!important;margin:0.5em 0px!important">Python 2.7</p>
</li>
<li style="margin:0.5em 0px"><p style="margin:1.2em 0px!important;margin:0.5em 0px!important">Ubuntu 12.04 and Windows 8</p>
</li>
</ul>
<p style="margin:1.2em 0px!important">Running the Charts example produces the error: </p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-bash" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)">..extending/chapter6-plugins/app.qml:<span class="hljs-number" style="color:rgb(0,128,128)">42</span> module <span class="hljs-string" style="color:rgb(221,17,68)">"Charts"</span> is not installed
</code></pre>
<p style="margin:1.2em 0px!important">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. </p>
<p style="margin:1.2em 0px!important">Here’s the Charts qmldir file.</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-bash" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)">module Charts
plugin pyqt5qmlplugin
</code></pre>
<p style="margin:1.2em 0px!important">I also tried modifying it to point to the directory with the <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">pyqt5qmlplugin</code> library.</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-bash" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)">module Charts
plugin `pyqt5qmlplugin` /home/marcus/Qt/<span class="hljs-number" style="color:rgb(0,128,128)">5.3</span>/gcc_64/plugins/PyQt5
</code></pre>
<p style="margin:1.2em 0px!important">If I understand correctly, the <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">pyqt5qmlplugin</code> 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”?</p>
<p style="margin:1.2em 0px!important">Is there any other examples of this in action? So far, this is the only mention of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">pyqt5qmlplugin</code> I’ve been able to find.</p>
<ul style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px"><a href="http://pyqt.sourceforge.net/Docs/PyQt5/qml.html#writing-python-plugins-for-qmlscene">http://pyqt.sourceforge.net/Docs/PyQt5/qml.html#writing-python-plugins-for-qmlscene</a></li>
</ul>
<p style="margin:1.2em 0px!important">Best,<br>Marcus</p>
<div title="MDH:SGksPGRpdj48YnI+PC9kaXY+PGRpdj5JJ20gYXR0ZW1wdGluZyB0byB3cml0ZSBhIFB5dGhvbiBw
bHVnLWluIGZvciBRTUwgYnV0IGFyZSBoYXZpbmcgaXNzdWVzIGluIGdldHRpbmcgaXQgdG8gd29y
ay48L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2Pi0gUHlRdDUgNS4zLjIvNS4zLjE8YnI+PC9kaXY+
PGRpdj4tIFF0IDUuMy4yLz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vcmdlLm5ldC9Eb2NzL1B5UXQ1L3FtbC5odG1sI3dyaXRp
bmctcHl0aG9uLXBsdWdpbnMtZm9yLXFtbHNjZW5lPC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5C
ZXN0LDwvZGl2PjxkaXY+TWFyY3VzPGJyIGNsZWFyPSJhbGwiPjxkaXY+PGJyPjwvZGl2PjwvZGl2
Pg==" style="height:0;font-size:0em;padding:0;margin:0"></div></div><div class="markdown-here-signature">-- <br><div class="gmail_signature"><div dir="ltr"><font size="1"><b>Marcus Ottosson</b><br><a href="mailto:konstruktion@gmail.com" target="_blank">konstruktion@gmail.com</a></font><font size="1"><br></font></div></div>
</div></div>