Skip to content

QObjectDetailsDialog

Qt Base Class: QMainWindow

Signature: QMainWindow(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, flags: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None

Base classes

Name Children Inherits
MainWindow
prettyqt.widgets.mainwindow

⋔ Inheritance diagram

graph TD
  1473367679072["debugging.QObjectDetailsDialog"]
  1473296227584["widgets.MainWindow"]
  1473293688240["widgets.WidgetMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473245548480["gui.PaintDeviceMixin"]
  1473290635936["QtWidgets.QMainWindow"]
  1473290849680["QtWidgets.QWidget"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473300082368["QtGui.QPaintDevice"]
  1473296227584 --> 1473367679072
  1473293688240 --> 1473296227584
  1473299815024 --> 1473293688240
  140713234304496 --> 1473299815024
  1473245548480 --> 1473293688240
  140713234304496 --> 1473245548480
  1473290635936 --> 1473296227584
  1473290849680 --> 1473290635936
  1473288842240 --> 1473290849680
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208
  1473300082368 --> 1473290849680
  1473291690208 --> 1473300082368

🛈 DocStrings

Bases: MainWindow

A dialog containing information about a QObject.

Source code in prettyqt\debugging\qobjectdetailsdialog.py
class QObjectDetailsDialog(widgets.MainWindow):
    """A dialog containing information about a QObject."""

    def __init__(
        self,
        qobject: core.QObject,
        *args,
        object_name="qobject_details_dialog",
        **kwargs,
    ):
        from prettyqt import ipython

        super().__init__(*args, object_name=object_name, **kwargs)
        self.qobject = qobject
        self.console = ipython.InProcessIPythonWidget(self)
        self.console.push_vars(dict(app=widgets.app(), qobject=qobject))
        self.tabwidget, self.propertyview = get_tabbed(qobject)
        self.hierarchyview = custom_widgets.QObjectHierarchyTreeView()
        self.hierarchyview.set_qobject(qobject)
        sel_model = self.hierarchyview.selectionModel()
        sel_model.currentRowChanged.connect(self._current_changed)
        self.logtable = custom_widgets.LogRecordTableView()
        self.logtable.set_logger(logging.getLogger())
        w = widgets.Widget()
        w.set_layout("vertical")
        self.stalkers = []
        stalker = debugging.Stalker(qobject, log_level=logging.DEBUG)
        stalker.hook()
        self.stalkers.append(stalker)
        for widget in qobject.find_children(widgets.QWidget):
            stalker = debugging.Stalker(widget, log_level=logging.DEBUG)
            stalker.hook()
            fn = functools.partial(self._on_widget_click, widget)
            stalker.leftclick_detected.connect(fn)
            self.stalkers.append(stalker)
        # mdi_area = widgets.GraphicsView()
        # subwindow = widgets.GraphicsProxyWidget ()
        # # mdi_area.installEventFilter(self)
        # # subwindow.installEventFilter(self)
        # subwindow.set_widget(qobject)
        # mdi_area.scene().add(subwindow)
        widget = widgets.Widget()
        layout = widget.set_layout("horizontal")
        layout.add(qobject)
        self.set_central_widget(widget)
        # qobject.position_on(widget)

        self.add_dockwidget(self.hierarchyview, window_title="Hierarchy view")
        self.add_dockwidget(self.tabwidget, window_title="Property view")
        self.add_dockwidget(self.logtable, window_title="Log", visible=False)
        self.add_dockwidget(self.console, window_title="Console", visible=False)
        self.menubar = self.menuBar()
        action = widgets.mainwindow.PopupMenuAction("Docks", parent=self)
        self.menubar.add_action(action)
        self.position_on("screen", scale_ratio=0.8)

    @classmethod
    def setup_example(cls):
        return None

    def eventFilter(self, source, event):
        match event.type():
            case core.QEvent.Type.MouseButtonRelease:
                raise ValueError
        return False

    def closeEvent(self, event):
        for stalker in self.stalkers:
            stalker.unhook()
        super().closeEvent(event)

    def _current_changed(self, new, old):
        # logger.info(f"{new=} {old=}")
        role = self.hierarchyview.get_model(skip_proxies=True).Roles.WidgetRole
        if (qobject := self.hierarchyview.current_data(role)) is not None:
            self.propertyview.set_qobject(qobject)

    def _on_widget_click(self, widget):
        logger.info(repr(widget))
        self.hierarchyview.select_object(widget)

__init__(qobject: core.QObject, *args: core.QObject, object_name: core.QObject = 'qobject_details_dialog', **kwargs: core.QObject)

Source code in prettyqt\debugging\qobjectdetailsdialog.py
def __init__(
    self,
    qobject: core.QObject,
    *args,
    object_name="qobject_details_dialog",
    **kwargs,
):
    from prettyqt import ipython

    super().__init__(*args, object_name=object_name, **kwargs)
    self.qobject = qobject
    self.console = ipython.InProcessIPythonWidget(self)
    self.console.push_vars(dict(app=widgets.app(), qobject=qobject))
    self.tabwidget, self.propertyview = get_tabbed(qobject)
    self.hierarchyview = custom_widgets.QObjectHierarchyTreeView()
    self.hierarchyview.set_qobject(qobject)
    sel_model = self.hierarchyview.selectionModel()
    sel_model.currentRowChanged.connect(self._current_changed)
    self.logtable = custom_widgets.LogRecordTableView()
    self.logtable.set_logger(logging.getLogger())
    w = widgets.Widget()
    w.set_layout("vertical")
    self.stalkers = []
    stalker = debugging.Stalker(qobject, log_level=logging.DEBUG)
    stalker.hook()
    self.stalkers.append(stalker)
    for widget in qobject.find_children(widgets.QWidget):
        stalker = debugging.Stalker(widget, log_level=logging.DEBUG)
        stalker.hook()
        fn = functools.partial(self._on_widget_click, widget)
        stalker.leftclick_detected.connect(fn)
        self.stalkers.append(stalker)
    # mdi_area = widgets.GraphicsView()
    # subwindow = widgets.GraphicsProxyWidget ()
    # # mdi_area.installEventFilter(self)
    # # subwindow.installEventFilter(self)
    # subwindow.set_widget(qobject)
    # mdi_area.scene().add(subwindow)
    widget = widgets.Widget()
    layout = widget.set_layout("horizontal")
    layout.add(qobject)
    self.set_central_widget(widget)
    # qobject.position_on(widget)

    self.add_dockwidget(self.hierarchyview, window_title="Hierarchy view")
    self.add_dockwidget(self.tabwidget, window_title="Property view")
    self.add_dockwidget(self.logtable, window_title="Log", visible=False)
    self.add_dockwidget(self.console, window_title="Console", visible=False)
    self.menubar = self.menuBar()
    action = widgets.mainwindow.PopupMenuAction("Docks", parent=self)
    self.menubar.add_action(action)
    self.position_on("screen", scale_ratio=0.8)

⌗ Property table

Qt Property Type Doc
objectName QString
modal bool
windowModality Qt::WindowModality
enabled bool
geometry QRect
frameGeometry QRect
normalGeometry QRect
x int
y int
pos QPoint
frameSize QSize
size QSize
width int
height int
rect QRect
childrenRect QRect
childrenRegion QRegion
sizePolicy QSizePolicy
minimumSize QSize
maximumSize QSize
minimumWidth int
minimumHeight int
maximumWidth int
maximumHeight int
sizeIncrement QSize
baseSize QSize
palette QPalette
font QFont
cursor QCursor
mouseTracking bool
tabletTracking bool
isActiveWindow bool
focusPolicy Qt::FocusPolicy
focus bool
contextMenuPolicy Qt::ContextMenuPolicy
updatesEnabled bool
visible bool
minimized bool
maximized bool
fullScreen bool
sizeHint QSize
minimumSizeHint QSize
acceptDrops bool
windowTitle QString
windowIcon QIcon
windowIconText QString
windowOpacity double
windowModified bool
toolTip QString
toolTipDuration int
statusTip QString
whatsThis QString
accessibleName QString
accessibleDescription QString
layoutDirection Qt::LayoutDirection
autoFillBackground bool
styleSheet QString
locale QLocale
windowFilePath QString
inputMethodHints QFlags
iconSize QSize
toolButtonStyle Qt::ToolButtonStyle
animated bool
documentMode bool
tabShape QTabWidget::TabShape
dockNestingEnabled bool
dockOptions QFlags
unifiedTitleAndToolBarOnMac bool

🖼 Screenshot