Skip to content

MappingModel

Qt Base Class: QAbstractTableModel

Signature: QAbstractTableModel(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
ListMixin
prettyqt.itemmodels.listmixin
AbstractTableModel
prettyqt.core.abstracttablemodel

⋔ Inheritance diagram

graph TD
  1473245468448["itemmodels.MappingModel"]
  1473299910672["itemmodels.ListMixin"]
  140713234304496["builtins.object"]
  1473299901888["core.AbstractTableModel"]
  1473299900912["core.AbstractTableModelMixin"]
  1473299890176["core.AbstractItemModelMixin"]
  1473299815024["core.ObjectMixin"]
  1473289054032["QtCore.QAbstractTableModel"]
  1473289050128["QtCore.QAbstractItemModel"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473299910672 --> 1473245468448
  140713234304496 --> 1473299910672
  1473299901888 --> 1473245468448
  1473299900912 --> 1473299901888
  1473299890176 --> 1473299900912
  1473299815024 --> 1473299890176
  140713234304496 --> 1473299815024
  1473289054032 --> 1473299901888
  1473289050128 --> 1473289054032
  1473288842240 --> 1473289050128
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: ListMixin, AbstractTableModel

Source code in prettyqt\itemmodels\mappingmodel.py
class MappingModel(itemmodels.ListMixin, core.AbstractTableModel):
    SUPPORTS = Sequence[dict]

    @classmethod
    def supports(cls, instance) -> bool:
        match instance:
            case (dict(), *_):
                return True
            case _:
                return False

    def columnCount(self, index: core.ModelIndex | None = None):
        return len(self.items[0]) if self.items else 0

    def headerData(
        self,
        section: int,
        orientation: constants.Orientation,
        role: constants.ItemDataRole = constants.DISPLAY_ROLE,
    ) -> str | None:
        match orientation, role:
            case constants.HORIZONTAL, constants.DISPLAY_ROLE:
                return list(self.items[0].keys())[section]

    def data(
        self,
        index: core.ModelIndex,
        role: constants.ItemDataRole = constants.DISPLAY_ROLE,
    ):
        item = self.data_by_index(index)
        match role:
            case constants.DISPLAY_ROLE:
                key = self.headerData(index.column(), constants.HORIZONTAL)
                return item[key]

Info

Supported data type: collections.abc.Sequence[dict]

⌗ Property table

Qt Property Type Doc
objectName QString