aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/extending/chapter1-basics/basics.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/extending/chapter1-basics/basics.py')
-rw-r--r--examples/declarative/extending/chapter1-basics/basics.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/examples/declarative/extending/chapter1-basics/basics.py b/examples/declarative/extending/chapter1-basics/basics.py
index 412b25cad..b05695800 100644
--- a/examples/declarative/extending/chapter1-basics/basics.py
+++ b/examples/declarative/extending/chapter1-basics/basics.py
@@ -47,10 +47,16 @@ import sys
from PySide6.QtCore import Property, Signal, QUrl
from PySide6.QtGui import QGuiApplication, QPen, QPainter, QColor
-from PySide6.QtQml import qmlRegisterType
+from PySide6.QtQml import QmlElement
from PySide6.QtQuick import QQuickPaintedItem, QQuickView
+# To be used on the @QmlElement decorator
+# (QML_IMPORT_MINOR_VERSION is optional)
+QML_IMPORT_NAME = "Charts"
+QML_IMPORT_MAJOR_VERSION = 1
+
+@QmlElement
class PieChart (QQuickPaintedItem):
nameChanged = Signal()
@@ -86,8 +92,6 @@ class PieChart (QQuickPaintedItem):
if __name__ == '__main__':
app = QGuiApplication(sys.argv)
- qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart')
-
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)
qml_file = os.fspath(Path(__file__).resolve().parent / 'app.qml')