QML_IMPORT_NAME = "io.qt.textproperties"
QML_IMPORT_MAJOR_VERSION = 1
@QmlElement
class Backend(QObject):
updated=Signal(str)
def init(self):
super().init()
self.updated.emit("IM")
if name == "main":
CURRENT_DIRECTORY = Path(file).resolve().parent
app = QGuiApplication(sys.argv)
format = QSurfaceFormat()
format.setSamples(4)
QSurfaceFormat.setDefaultFormat(format)
engine = QQmlApplicationEngine()
engine.addImportPath(f"{os.path.dirname(file)}")
QQuickStyle.setStyle("CStyles")
engine.setOfflineStoragePath(os.fspath(CURRENT_DIRECTORY))
backend = Backend()
engine.load(os.fspath(CURRENT_DIRECTORY / "main.qml"))
engine.rootObjects()[0].setProperty('sender', backend)
engine.quit.connect(app.quit)
def handle_status_changed(status):
if status == QQuickView.Error:
QtCore.QCoreApplication.exit(-1)
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec())