diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-01-20 17:33:10 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-01-21 07:54:26 +0100 |
commit | d898e002380e2b8808592b6e0e05c689e1b37bd8 (patch) | |
tree | 91fbe2d3dda6bad336073dae9802a4568e37f1bf /examples/declarative/extending/chapter5-listproperties | |
parent | 935ccfefad7f78d56d61d3791ecb0a8491f72052 (diff) |
Examples: Remove remaining qmlRegisterType()
Pick-to: 6.2
Task-number: PYSIDE-841
Change-Id: I2c3f9b22a3c1fdc6ddbdd7f08db38db613274cfd
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/declarative/extending/chapter5-listproperties')
-rw-r--r-- | examples/declarative/extending/chapter5-listproperties/listproperties.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/declarative/extending/chapter5-listproperties/listproperties.py b/examples/declarative/extending/chapter5-listproperties/listproperties.py index eeaba0858..8ea36c11c 100644 --- a/examples/declarative/extending/chapter5-listproperties/listproperties.py +++ b/examples/declarative/extending/chapter5-listproperties/listproperties.py @@ -47,10 +47,16 @@ import sys from PySide6.QtCore import Property, QUrl from PySide6.QtGui import QGuiApplication, QPen, QPainter, QColor -from PySide6.QtQml import qmlRegisterType, ListProperty +from PySide6.QtQml import QmlElement, ListProperty from PySide6.QtQuick import QQuickPaintedItem, QQuickView, QQuickItem +# To be used on the @QmlElement decorator +# (QML_IMPORT_MINOR_VERSION is optional) +QML_IMPORT_NAME = "Charts" +QML_IMPORT_MAJOR_VERSION = 1 + +@QmlElement class PieSlice (QQuickPaintedItem): def __init__(self, parent=None): QQuickPaintedItem.__init__(self, parent) @@ -89,6 +95,7 @@ class PieSlice (QQuickPaintedItem): painter.drawPie(self.boundingRect().adjusted(1, 1, -1, -1), self._fromAngle * 16, self._angleSpan * 16) +@QmlElement class PieChart (QQuickItem): def __init__(self, parent=None): QQuickItem.__init__(self, parent) @@ -113,9 +120,6 @@ class PieChart (QQuickItem): if __name__ == '__main__': app = QGuiApplication(sys.argv) - qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart') - qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice") - view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) qml_file = os.fspath(Path(__file__).resolve().parent / 'app.qml') |