[PyQt] PyQt 5.1 App doesn't exit after QQuickView closed
Glenn Ramsey
gr at componic.co.nz
Mon Aug 26 22:26:55 BST 2013
Hi,
In the following example, the application doesn't exit after the QQuickView
window is closed. Is this the correct behaviour or is it a bug? This is using
snapshot-693a95fde3fa on OSX 10.8.4 with Qt 5.1, PyQt 5.1 and macports python
built as 32 bit.
Glenn
import sys
import os
from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtQuick
def main():
app = QtWidgets.QApplication(sys.argv)
quickview = QtQuick.QQuickView()
if getattr(sys, 'frozen', None):
basedir = sys._MEIPASS
else:
basedir = os.path.dirname(__file__)
quickview.setSource(QtCore.QUrl.fromLocalFile(os.path.join(basedir,
'hello.qml')))
quickview.show()
app.exec_()
if __name__ == "__main__":
main()
hello.qml:
import QtQuick 2.0
Rectangle {
width: 360
height: 360
Text {
anchors.centerIn: parent
text: "Hello World"
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}
More information about the PyQt
mailing list