From c662c744cf91f966dbc072afc6d433dbfed380fb Mon Sep 17 00:00:00 2001 From: Shyamnath Premnadh Date: Sat, 24 Sep 2022 10:59:40 +0200 Subject: QtQuick Example: Use QmlElement instead of qmlRegisterType - The example used the old way of registering the Qml type using the qmlRegisterType(). This is now updated to use the @QmlElement decorator. This would also make it work with pyside6-qml. Pick-to: 6.3 Change-Id: I97e5233331f01fcaa58ca8d6ffa9d978d6d31e91 Reviewed-by: Friedemann Kleint --- examples/quick/painteditem/painteditem.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/quick/painteditem/painteditem.py b/examples/quick/painteditem/painteditem.py index dc9575e67..180e22943 100644 --- a/examples/quick/painteditem/painteditem.py +++ b/examples/quick/painteditem/painteditem.py @@ -6,11 +6,16 @@ import sys from PySide6.QtGui import QPainter, QBrush, QColor from PySide6.QtWidgets import QApplication -from PySide6.QtQml import qmlRegisterType +from PySide6.QtQml import QmlElement from PySide6.QtCore import QUrl, Property, Signal, Qt, QPointF from PySide6.QtQuick import QQuickPaintedItem, QQuickView +QML_IMPORT_NAME = "TextBalloonPlugin" +QML_IMPORT_MAJOR_VERSION = 1 +QML_IMPORT_MINOR_VERSION = 0 # Optional + +@QmlElement class TextBalloon(QQuickPaintedItem): rightAlignedChanged = Signal() @@ -60,7 +65,6 @@ if __name__ == "__main__": app = QApplication(sys.argv) view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) - qmlRegisterType(TextBalloon, "TextBalloonPlugin", 1, 0, "TextBalloon") qml_file = Path(__file__).parent / "main.qml" view.setSource(QUrl.fromLocalFile(qml_file)) -- cgit v1.2.3