From c9330b0acf680d4c2a0933b8bf67dc9b3114de5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Mon, 28 Jun 2021 16:42:55 +0200 Subject: qml: replace context properties and code updates Most of the qml code in the repository was outdated, and followed bad practices, like context properties. Complementary, after the major updates for Qt6 most of the code was not relying on the new ways of register types (singletons, and using the decorator QmlElement). Drop the context property usage in the following examples: - signals/qmltopy1 - signals/qmltopy2 - signals/pytoqml2 - usingmodel - quickcontrols2/gallery - textproperties Additionally: - all the tests related to context properties - tutorials/qmlapp - tutorials/qmlsqlintegration - Removing 'scrolling' example - Fixing some flake8 warnings Change-Id: I649248c0149876bf2bf94e78e27cef7110f42f1d Reviewed-by: Friedemann Kleint Reviewed-by: Qt CI Bot Reviewed-by: Keith Kyzivat --- sources/pyside6/tests/QtQml/bug_814.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sources/pyside6/tests/QtQml/bug_814.py') diff --git a/sources/pyside6/tests/QtQml/bug_814.py b/sources/pyside6/tests/QtQml/bug_814.py index 05cd440f1..599a95e87 100644 --- a/sources/pyside6/tests/QtQml/bug_814.py +++ b/sources/pyside6/tests/QtQml/bug_814.py @@ -51,8 +51,12 @@ from helper.timedqapplication import TimedQApplication from PySide6.QtCore import QUrl, QAbstractListModel, QModelIndex, Qt from PySide6.QtQuick import QQuickView +from PySide6.QtQml import QmlElement +QML_IMPORT_NAME = "test.ListModel" +QML_IMPORT_MAJOR_VERSION = 1 +@QmlElement class ListModel(QAbstractListModel): def __init__(self): super().__init__() @@ -73,7 +77,7 @@ class TestBug814(TimedQApplication): def testAbstractItemModelTransferToQML(self): view = QQuickView() model = ListModel() - view.rootContext().setContextProperty("pythonModel", model) + view.setInitialProperties({"pythonModel": model}) file = Path(__file__).resolve().parent / 'bug_814.qml' self.assertTrue(file.is_file()) view.setSource(QUrl.fromLocalFile(file)) -- cgit v1.2.3