<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-01-06 16:29 GMT+01:00 Dietmar Schwertberger <span dir="ltr"><<a href="mailto:maillist@schwertberger.de" target="_blank">maillist@schwertberger.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">On 06.01.2016 15:46, Phil Thompson wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I have experimented with ways of eliminating the need for QML. The main problem is that the internal architecture of QML/Quick etc is, let's say, not state of the art. (In the Trolltech days they never would have released something so badly designed.)<br>
<br>
QML is fine for what it does - which isn't very much. I would treat it just as a way of creating GUIs (ie. implement views in QML, but implement models and controllers in Python). While you can implement lots more in QML I wouldn't recommend it because it's not easy to re-use or extend code or to manage large amounts of code.<br>
</blockquote></span>
Yes, for pure markup QML would be OK.<br>
It would help a lot if it would be possible to just define the basic GUI in QML, but connect events, fill the widgets etc. from Python without all the JavaScript mess.<br>
E.g.<br>
self.GUI = qt.load("GUI.qml")<br>
self.GUI.windows["Main"].widgets["Play"].connect(self.OnPlay)<br>
self.GUI.windows["Main"].widgets["list"].fill( ["Title 1", "Title 2"] ) # for a short list, otherwise use MVC<br>
<br>
def OnPlay(self, event):<br>
    track_index = self.GUI.forms["Main"].widgets["list"].getIndex()<br></blockquote><div><br></div><div>You can kinda do that in PyOtherSide - but the other way around. You write the "backend" code in Python and then import and call it from QML. See the PyOtherSide examples[0], such as the notes one[1][2] as an example.<br><br></div><div>Also recently support for working with QObjects passed from QML to Python has been added - which sounds kinda like the thing you propose. An example from the docs[3]:<br><br><pre><span class=""># Assume func will be called with a QObject as sole argument</span>
<span class="">def</span> <span class="">func</span><span class="">(</span><span class="">qobject</span><span class="">):</span>
    <span class=""># Getting properties</span>
    <span class="">print</span><span class="">(</span><span class="">qobject</span><span class="">.</span><span class="">x</span><span class="">)</span>

    <span class=""># Setting properties</span>
    <span class="">qobject</span><span class="">.</span><span class="">x</span> <span class="">=</span> <span class="">123</span>

    <span class=""># Calling slots and dynamic functions</span>
    <span class="">print</span><span class="">(</span><span class="">qobject</span><span class="">.</span><span class="">someFunction</span><span class="">(</span><span class="">123</span><span class="">,</span> <span class="">'b'</span><span class="">))</span>

    <span class=""># Returning a QObject reference to the caller</span>
    <span class="">return</span> <span class="">qobject</span><br><br></pre></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Currently, Qt Quick is a no-go for me. I had a close look and I don't like it...<br>
<br>
Regards,<br>
<br>
Dietmar<div class=""><div class="h5"><br></div></div></blockquote><div>[0] <a href="https://github.com/thp/pyotherside/tree/master/examples">https://github.com/thp/pyotherside/tree/master/examples</a><br>[1] <a href="https://github.com/thp/pyotherside/blob/master/examples/notes_example.py">https://github.com/thp/pyotherside/blob/master/examples/notes_example.py</a><br>[2] <a href="https://github.com/thp/pyotherside/blob/master/examples/notes_example.qml">https://github.com/thp/pyotherside/blob/master/examples/notes_example.qml</a><br>[3] <a href="http://pyotherside.readthedocs.org/en/latest/#accessing-qobjects-from-python">http://pyotherside.readthedocs.org/en/latest/#accessing-qobjects-from-python</a> <br></div></div></div></div>