aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2022-09-24 10:59:40 +0200
committerShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2022-09-27 11:45:30 +0200
commitc662c744cf91f966dbc072afc6d433dbfed380fb (patch)
tree1fe6f7567cba5f82fc05316ebc2a0303b37ba018 /examples/quick
parent4669e8ef08eeb4dc81df04214807e9c4da8fc965 (diff)
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 <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/painteditem/painteditem.py8
1 files 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))