<div dir="ltr"><div>Ran across some unexpected behavior while fiddling with QML.. See comments in python source below.</div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">Windows 7, Python 3.3.2 x86</font></div>
<div><font face="courier new, monospace">PYQT_VERSION_STR = 5.2.1-snapshot-c8f5b569c377<br></font></div><div><font face="courier new, monospace">SIP_VERSION_STR = 4.15.5-snapshot-d45411f2a001</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">Thanks,</font></div><div><font face="courier new, monospace">Michael</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">// ---- return.qml ----</font></div>
<div><font face="courier new, monospace"><br></font></div><div><div><font face="courier new, monospace">import QtQuick 2.0</font></div><div><font face="courier new, monospace">import QtQuick.Controls 1.1</font></div><div>
<font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">ApplicationWindow {</font></div><div><font face="courier new, monospace"> id: main; visible: true;</font></div><div><font face="courier new, monospace"> function logThing(thing) { console.log(JSON.stringify(thing)); }</font></div>
<div><font face="courier new, monospace"> function getThing(a) { return a; }</font></div><div><font face="courier new, monospace">}</font></div></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"># ---- return.py ----</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><div>import sys</div><div>from PyQt5.QtWidgets import QApplication</div><div>from PyQt5.QtQml import QQmlApplicationEngine</div>
<div><br></div><div>if __name__ == '__main__':</div><div> app = QApplication(sys.argv)</div><div> eng = QQmlApplicationEngine('return.qml')</div><div> root = eng.rootObjects()[0]</div><div> root.logThing({'a': 42}) # works</div>
<div> print (root.getThing('simple')) # works</div><div> print (root.getThing({'b': 41})) # Crash or sometimes an error: </div><div> # "Trying to construct an instance of an invalid type, type id: <#>"</div>
<div> # and None is printed</div><div> sys.exit(app.exec_())</div><div><br></div></font></div></div>