aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/usingmodel/usingmodel.py
diff options
context:
space:
mode:
authorFriedemann Kleint <[email protected]>2024-09-18 07:36:20 +0200
committerFriedemann Kleint <[email protected]>2024-09-18 08:28:04 +0200
commite4199ec3881d8e556385af98084856be857e0dbe (patch)
tree77b264f5a21cff9f131a6b27e3b5142745faf91f /examples/qml/usingmodel/usingmodel.py
parentf48433db9a5be32c0b401c1d5203853abbff6c32 (diff)
type hints: Fix some typing bugs for mypy (forgiveness)
The new enums still support old syntax by the forgiveness mode. Nevertheless, when using mypy to check files, strict correctness is enforced. We correct a large number of forgiveness-induced errors, but there is still a whole lot of other complaints to fix. Task-number: PYSIDE-2846 Change-Id: If566187d268ef75bc09b8d86f73d2c7d19f284f9 Reviewed-by: Friedemann Kleint <[email protected]>
Diffstat (limited to 'examples/qml/usingmodel/usingmodel.py')
-rw-r--r--examples/qml/usingmodel/usingmodel.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/qml/usingmodel/usingmodel.py b/examples/qml/usingmodel/usingmodel.py
index d02fb8524..80413316d 100644
--- a/examples/qml/usingmodel/usingmodel.py
+++ b/examples/qml/usingmodel/usingmodel.py
@@ -25,7 +25,7 @@ class Person:
@QmlElement
@QmlSingleton
class PersonModel (QAbstractListModel):
- MyRole = Qt.UserRole + 1
+ MyRole = Qt.ItemDataRole.UserRole + 1
def __init__(self, data, parent=None):
super().__init__(parent)
@@ -34,7 +34,7 @@ class PersonModel (QAbstractListModel):
def roleNames(self):
roles = {
PersonModel.MyRole: QByteArray(b'myrole'),
- Qt.DisplayRole: QByteArray(b'display')
+ Qt.ItemDataRole.DisplayRole: QByteArray(b'display')
}
return roles
@@ -43,9 +43,9 @@ class PersonModel (QAbstractListModel):
def data(self, index, role):
d = self._data[index.row()]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
return d.name
- if role == Qt.DecorationRole:
+ if role == Qt.ItemDataRole.DecorationRole:
return Qt.black
if role == PersonModel.MyRole:
return d.myrole
@@ -64,7 +64,7 @@ if __name__ == '__main__':
qml_file = os.fspath(Path(__file__).resolve().parent / 'view.qml')
view.setSource(QUrl.fromLocalFile(qml_file))
- if view.status() == QQuickView.Error:
+ if view.status() == QQuickView.Status.Error:
sys.exit(-1)
view.show()