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 | |
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')
5 files changed, 37 insertions, 17 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') diff --git a/examples/declarative/extending/chapter2-methods/methods.py b/examples/declarative/extending/chapter2-methods/methods.py index c9e7be8f3..b068cd220 100644 --- a/examples/declarative/extending/chapter2-methods/methods.py +++ b/examples/declarative/extending/chapter2-methods/methods.py @@ -47,10 +47,16 @@ import sys from PySide6.QtCore import Property, Signal, Slot, Qt, 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): chartCleared = Signal() @@ -93,8 +99,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') diff --git a/examples/declarative/extending/chapter3-bindings/bindings.py b/examples/declarative/extending/chapter3-bindings/bindings.py index cacac78da..17394d6ea 100644 --- a/examples/declarative/extending/chapter3-bindings/bindings.py +++ b/examples/declarative/extending/chapter3-bindings/bindings.py @@ -47,10 +47,16 @@ import sys from PySide6.QtCore import Property, Signal, Slot, QUrl, Qt 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): chartCleared = Signal() @@ -97,8 +103,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') diff --git a/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py b/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py index a4a74fef4..ce8fd4294 100644 --- a/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py +++ b/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.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 +from PySide6.QtQml import QmlElement 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): @@ -72,6 +78,7 @@ class PieSlice (QQuickPaintedItem): painter.drawPie(self.boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16) +@QmlElement class PieChart (QQuickItem): def __init__(self, parent=None): QQuickItem.__init__(self, parent) @@ -99,9 +106,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') 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') |