-
Notifications
You must be signed in to change notification settings - Fork 6
/
QmlViewer.py
34 lines (24 loc) · 954 Bytes
/
QmlViewer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# univerzální prohlížeč QML souborů
import sys
# import "jádra" frameworku Qt i modulu pro GUI
# modul pro práci s QML
from PySide2 import QtCore, QtGui, QtQuick
# nový widget bude odvozen od QDeclarativeView
class MainWindow(QtQuick.QQuickView):
def __init__(self, qml_file, parent=None):
super(MainWindow, self).__init__(parent)
# nastavení titulku hlavního okna aplikace
self.setTitle("QML Example @ PySide2: " + qml_file)
# načtení souboru QML
self.setSource(QtCore.QUrl.fromLocalFile(qml_file))
# necháme QML změnit velikost okna
self.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView)
def main(qml_file):
# vytvoření Qt aplikace
app = QtGui.QGuiApplication(sys.argv)
# vytvoření hlavního okna
window = MainWindow(qml_file)
# zobrazení hlavního okna na desktopu
window.show()
# spuštění aplikace
sys.exit(app.exec_())