QGuiApplication QQmlApplicationEngine load and display QML Window

 

 1 import sys
 2 
 3 from PyQt5.QtCore import QUrl
 4 from PyQt5.QtGui import QGuiApplication
 5 from PyQt5.QtQml import QQmlApplicationEngine
 6 
 7 if __name__ == '__main__':
 8     app = QGuiApplication(sys.argv)
 9 
10     engine = QQmlApplicationEngine()
11     engine.load(QUrl('table.qml'))
12 
13     sys.exit(app.exec())

 

 

 1 import QtQuick 2.15
 2 import QtQuick.Window 2.15
 3 
 4 Window {
 5     visible: true
 6     width: 400
 7     height: 300
 8     title: "Hello World"
 9 
10     Text { text: "Hello World"}
11 }

 

posted @ 2025-04-21 17:49  dilex  阅读(17)  评论(0)    收藏  举报