aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/editingmodel
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-01-20 17:33:10 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-01-21 07:54:26 +0100
commitd898e002380e2b8808592b6e0e05c689e1b37bd8 (patch)
tree91fbe2d3dda6bad336073dae9802a4568e37f1bf /examples/declarative/editingmodel
parent935ccfefad7f78d56d61d3791ecb0a8491f72052 (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/editingmodel')
-rw-r--r--examples/declarative/editingmodel/main.py3
-rw-r--r--examples/declarative/editingmodel/model.py7
2 files changed, 8 insertions, 2 deletions
diff --git a/examples/declarative/editingmodel/main.py b/examples/declarative/editingmodel/main.py
index 6aee0d224..34fcadc40 100644
--- a/examples/declarative/editingmodel/main.py
+++ b/examples/declarative/editingmodel/main.py
@@ -43,13 +43,12 @@ from pathlib import Path
from PySide6.QtCore import QUrl
from PySide6.QtGui import QGuiApplication
-from PySide6.QtQml import QQmlApplicationEngine, qmlRegisterType
+from PySide6.QtQml import QQmlApplicationEngine
from model import BaseModel
if __name__ == "__main__":
app = QGuiApplication(sys.argv)
- qmlRegisterType(BaseModel, "BaseModel", 1, 0, "BaseModel")
engine = QQmlApplicationEngine()
qml_file = Path(__file__).parent / "main.qml"
engine.load(QUrl.fromLocalFile(qml_file))
diff --git a/examples/declarative/editingmodel/model.py b/examples/declarative/editingmodel/model.py
index 99736e714..ae9c59d33 100644
--- a/examples/declarative/editingmodel/model.py
+++ b/examples/declarative/editingmodel/model.py
@@ -42,8 +42,15 @@
from PySide6.QtCore import (QAbstractListModel, QByteArray, QModelIndex, Qt,
Slot)
from PySide6.QtGui import QColor
+from PySide6.QtQml import QmlElement
+# To be used on the @QmlElement decorator
+# (QML_IMPORT_MINOR_VERSION is optional)
+QML_IMPORT_NAME = "BaseModel"
+QML_IMPORT_MAJOR_VERSION = 1
+
+@QmlElement
class BaseModel(QAbstractListModel):
RatioRole = Qt.UserRole + 1