"""Create a Simple Quick Application""" import sys from PySide6.QtGui import QGuiApplication from PySide6.QtQml import QQmlApplicationEngine QML = """ import QtQuick import QtQuick.Controls import QtQuick.Layouts Window { width: 300 height: 200 visible: true title: "Hello World" readonly property list<string> texts: ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир", "您好,世界!"] function setText() { var i = Math.round(Math.random() * 3) text.text = texts[i] } ColumnLayout { anchors.fill: parent Text { id: text text: "Hello World" Layout.alignment: Qt.AlignHCenter } Button { text: "Click me" Layout.alignment: Qt.AlignHCenter onClicked: setText() } } } """ if __name__ == "__main__": app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() engine.loadData(QML.encode('utf-8')) if not engine.rootObjects(): sys.exit(-1) exit_code = app.exec() del engine sys.exit(exit_code)
标签:__,Qt,text,py,sys,exit,import,world From: https://www.cnblogs.com/zdt168/p/18353059