Skip to content

WidgetHierarchyModel

Qt Base Class: QAbstractItemModel

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

Base classes

Name Children Inherits
BaseHierarchyModel
prettyqt.itemmodels.widgethierarchymodel

⋔ Inheritance diagram

graph TD
  1473290715968["itemmodels.WidgetHierarchyModel"]
  1473290713040["itemmodels.BaseHierarchyModel"]
  1473299686192["itemmodels.TreeModel"]
  1473299893104["core.AbstractItemModel"]
  1473299890176["core.AbstractItemModelMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473289050128["QtCore.QAbstractItemModel"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473290713040 --> 1473290715968
  1473299686192 --> 1473290713040
  1473299893104 --> 1473299686192
  1473299890176 --> 1473299893104
  1473299815024 --> 1473299890176
  140713234304496 --> 1473299815024
  1473289050128 --> 1473299893104
  1473288842240 --> 1473289050128
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: BaseHierarchyModel

Tree model showing the child tree of a QObject.

Source code in prettyqt\itemmodels\widgethierarchymodel.py
class WidgetHierarchyModel(BaseHierarchyModel):
    """Tree model showing the child tree of a QObject."""

    SUPPORTS = core.QObject

    @classmethod
    def supports(cls, instance) -> bool:
        return isinstance(instance, core.QObject)

    def _fetch_object_children(
        self, item: WidgetHierarchyModel.TreeItem
    ) -> list[WidgetHierarchyModel.TreeItem]:
        return [
            self.TreeItem(obj=i)
            for i in item.obj.findChildren(
                self.BaseClass, None, constants.FindChildOption.FindDirectChildrenOnly
            )
        ]

    def _has_children(self, item: WidgetHierarchyModel.TreeItem) -> bool:
        return bool(
            item.obj.findChildren(
                self.BaseClass, None, constants.FindChildOption.FindDirectChildrenOnly
            )
        )

Info

Supported data type: <class 'PySide6.QtCore.QObject'>

⌗ Property table

Qt Property Type Doc
objectName QString
base_class_name QString Class to use for the columns.