<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I'm trying to modify the example given in
<a class="moz-txt-link-freetext" href="https://www.riverbankcomputing.com/static/Docs/PyQt5/qml.html">https://www.riverbankcomputing.com/static/Docs/PyQt5/qml.html</a> by
including a JS function in the `example.qml` file such that I can
invoke that from Python.</p>
<p>Let's say I change `example.qml` to</p>
<pre style="overflow: auto hidden; clear: both; padding: 5px; background-color: unset; color: rgb(0, 0, 0); line-height: 15.6px; border-top: 1px solid rgb(170, 204, 153); border-bottom: 1px solid rgb(170, 204, 153); border-image: initial; border-left: none; border-right: none; margin: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span class="kn" style="color: rgb(0, 112, 32); font-weight: bold;">import</span> <span class="nn" style="color: rgb(14, 132, 181); font-weight: bold;">People</span> <span class="mf" style="color: rgb(32, 128, 80);">1.0</span>
<span class="n">Person</span> <span class="p">{</span>
<span class="n">name</span><span class="p">:</span> <span class="s2" style="color: rgb(64, 112, 160);">"Bob Jones"</span>
<span class="n">shoeSize</span><span class="p">:</span> <span class="mi" style="color: rgb(32, 128, 80);">12</span>
function greet() { console.log("Hello World !")}
<span class="p">}</span></pre>
<p><br>
</p>
<p>I'm then trying to call the new method from Python, but neither
`person.greet()` nor `QMetaObject.invokeMethod(person, 'greet')`
work. What is the right way to access and call a QML function from
Python ? <br>
</p>
<p>Thanks,<br>
</p>
<div class="moz-signature">
<div class="moz-signature">
<div class="moz-signature">
<pre><img moz-do-not-send="false" src="cid:part1.373884D0.75C56256@seefeld.name" alt="Stefan" width="123" height="77">
--
...ich hab' noch einen Koffer in Berlin...
</pre>
</div>
</div>
</div>
</body>
</html>