Skip to content

QmlPropertyMap

Base classes

Name Children Inherits
QmlPropertyMapMixin
prettyqt.qml.qmlpropertymap
QQmlPropertyMap
PySide6.QtQml
QQmlPropertyMap(self, /, parent: PySide6.QtCore.QObject | None \= None) -> None
MutableMapping
collections.abc
A MutableMapping is a generic container for associating

⋔ Inheritance diagram

graph TD
  2436162881["qml.QmlPropertyMap"]
  2880585937["qml.QmlPropertyMapMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  478565633["QtQml.QQmlPropertyMap"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  1799060090["abc.MutableMapping"]
  4016029557["abc.Mapping"]
  2852422536["abc.Collection"]
  4051874921["abc.Sized"]
  2021119437["abc.Iterable"]
  1031828782["abc.Container"]
  2880585937 --> 2436162881
  3227531497 --> 2880585937
  2751680898 --> 3227531497
  2751680898 --> 2880585937
  478565633 --> 2436162881
  3984060476 --> 478565633
  37984305 --> 3984060476
  2751680898 --> 37984305
  1799060090 --> 2436162881
  4016029557 --> 1799060090
  2852422536 --> 4016029557
  4051874921 --> 2852422536
  2751680898 --> 4051874921
  2021119437 --> 2852422536
  2751680898 --> 2021119437
  1031828782 --> 2852422536
  2751680898 --> 1031828782

🛈 DocStrings

Bases: QmlPropertyMapMixin, QQmlPropertyMap, MutableMapping

Allows you to set key-value pairs that can be used in QML bindings.

Source code in prettyqt/qml/qmlpropertymap.py
class QmlPropertyMap(
    QmlPropertyMapMixin,
    QtQml.QQmlPropertyMap,
    MutableMapping,
    metaclass=datatypes.QABCMeta,
):
    """Allows you to set key-value pairs that can be used in QML bindings."""

    def __repr__(self):
        return get_repr(self, dict(self))

    def __setitem__(self, key: str, value: datatypes.Variant):
        self.insert(key, value)

    def __getitem__(self, key: str) -> datatypes.Variant:
        if not self.contains(key):
            raise KeyError(key)
        return self.value(key)

    def __delitem__(self, key: str):
        self.clear(key)

    def __contains__(self, key):
        return self.contains(key)

    def __bool__(self):
        return not self.isEmpty()

    def __iter__(self):
        return iter(self.keys())

    def __len__(self):
        return self.count()

:fa-brands-github: Show source on GitHub