Skip to content

Instantly share code, notes, and snippets.

@spooky
Created August 23, 2017 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spooky/d494bfcfd9ef74587d0261fc39ea83be to your computer and use it in GitHub Desktop.
Save spooky/d494bfcfd9ef74587d0261fc39ea83be to your computer and use it in GitHub Desktop.
qml crash after close
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQml import QQmlApplicationEngine
def run():
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(QUrl('main.qml'))
if not engine.rootObjects():
return -1
return app.exec_()
if __name__ == '__main__':
sys.exit(run())
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
FileDialog {
id: fileDialog
selectFolder: true
onAccepted: {
console.log('activated')
}
}
Button {
anchors.centerIn: parent
text: "Open"
onClicked: {
fileDialog.open()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment