<div dir="ltr">No sure what is wrong with yours, but I'm using a QQuickView inside a QApplication and it work well.<div><br></div><div>import sys<br></div><div><div><br></div><div>from PyQt5.QtCore import QSettings, QUrl, QRect, pyqtSignal, pyqtSlot</div><div>from PyQt5.QtWidgets import QApplication</div><div>from PyQt5.QtQuick import QQuickView, QQuickWindow</div><div><br></div><div>class MyQmlApplication(QApplication):</div><div> _application_name = "UNDEFINED"</div><div> _qquickview = None</div><div> _engine = None</div><div> _settings = None</div><div> </div><div> def __init__(self, title, args):</div><div> QApplication.__init__(self, args)</div><div> self._qquickview = QQuickView()</div><div> self._qquickview.setTitle(title)</div><div> self._qquickview.setResizeMode(QQuickView.SizeRootObjectToView)</div><div> self._qquickview.setGeometry(QRect(100,100,600,800))</div><div> self._engine = self._qquickview.engine()</div><div> </div><div> def showAndExec(self, qml_url):</div><div> self._qquickview.setSource(qml_url)</div><div> self._qquickview.show()</div><div> return self.exec_()</div><div><br></div><div>app = BodycadQmlApplication("MyAppTitle", sys.argv)</div><div>app.showAndExec(QUrl("Main.qml"))</div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 25, 2016 at 10:43 AM, Daniel Krause <span dir="ltr"><<a href="mailto:madakr@web.de" target="_blank">madakr@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:12.8px">Hello,</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I am new to PyQt and having trouble to include QML-Code into an python application.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">The QML-File (main.qml) I can build in a project in QtCreator (a Qt Quick Application was used to create the project).</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div>import QtQuick 2.5</div><div>import QtQuick.Controls 1.4</div><div>import QtQuick.Dialogs 1.2</div><div>import QtQml.Models 2.1</div><div><br></div><div>ApplicationWindow {</div><div> visible: true</div><div> width: 640</div><div> height: 480</div><div> title: qsTr("Hello World")</div><div><br></div><div> menuBar: MenuBar {</div><div> Menu {</div><div> title: qsTr("File")</div><div> MenuItem {</div><div> text: qsTr("&Open")</div><div> onTriggered: console.log("Open action triggered");</div><div> }</div><div> MenuItem {</div><div> text: qsTr("Exit")</div><div> onTriggered: Qt.quit();</div><div> }</div><div> }</div><div> }</div><div><br></div><div> MainForm {</div><div> id: mainForm1</div><div> anchors.fill: parent</div><div><br></div><div> SplitView {</div><div> id: splitView1</div><div> width: 100</div><div> anchors.left: parent.left</div><div> anchors.leftMargin: 36</div><div> anchors.bottom: parent.bottom</div><div> anchors.bottomMargin: 8</div><div> anchors.top: parent.top</div><div> anchors.topMargin: 8</div><div> orientation: Qt.Vertical</div><div><br></div><div><br></div><div> Button {</div><div> id: btn_welcome</div><div> x: 49</div><div> y: 21</div><div> text: qsTr("Welcome")</div><div> }</div><div><br></div><div> Button {</div><div> id: btn_database</div><div> x: 49</div><div> y: 50</div><div> text: qsTr("Database")</div><div> }</div><div><br></div><div> MouseArea {</div><div> id: mouseArea1</div><div> x: 0</div><div> y: 191</div><div> width: 100</div><div> height: 100</div><div> }</div><div> }</div><div> }</div><div>}</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">It results in the following window:</div><div style="font-size:12.8px"><img src="cid:ii_1530fb7a3e1f8292" alt="Inline-Bild 1" width="412" height="329"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">To create the application in Python I tried to use QGuiApplication and QQmlApplicationEngine. </div><div style="font-size:12.8px">main.py and main.qml are located in the same directory:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div>import sys</div><div>from PyQt5.QtQml import QQmlApplicationEngine</div><div>from PyQt5.QtGui import QGuiApplication</div><div><br></div><div>if __name__ == '__main__':</div><div> app = QGuiApplication(sys.argv)</div><div> engine = QQmlApplicationEngine("main.qml")</div><div> print(engine)</div><div> sys.exit(app.exec_())</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">The print()-statement is never executed, no window is appearing.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">What did I miss?</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thanks in advance</div><span class="HOEnZb"><font color="#888888"><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Daniel</div></font></span></div>
<br>_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br></div>