Skip to content

SGNode

Base classes

Name Children Inherits
QSGNode
PySide6.QtQuick
QSGNode(self, /) -> None

⋔ Inheritance diagram

graph TD
  3825566987["quick.SGNode"]
  1726843577["QtQuick.QSGNode"]
  37984305["Shiboken.Object"]
  2751680898["builtins.object"]
  1726843577 --> 3825566987
  37984305 --> 1726843577
  2751680898 --> 37984305

🛈 DocStrings

Bases: QSGNode

The base class for all nodes in the scene graph.

Source code in prettyqt/quick/sgnode.py
class SGNode(QtQuick.QSGNode):
    """The base class for all nodes in the scene graph."""

    def __getitem__(self, index: int) -> QtQuick.QSGNode:
        return self.childAtIndex(index)

    def __delitem__(self, item: int | QtQuick.QSGNode):
        if isinstance(item, int):
            item = self.childAtIndex(item)
        self.removeChildNode(item)

    def get_type(self) -> NodeTypeStr:
        """Get the type of the node.

        Returns:
            Node type
        """
        return NODE_TYPE.inverse[self.type()]

    def get_flags(self) -> list[FlagStr]:
        return FLAG.get_list(self.flags())

    def get_children(self, recursive: bool = False) -> list[QtQuick.QSGNode]:
        """Get children of this item.

        recursive option is written iteratively to also support original QTreeWidgetItems.
        """
        if not recursive:
            return [self.childAtIndex(i) for i in range(self.childCount())]
        results = []
        nodes = [self]
        while nodes:
            items = []
            for node in nodes:
                results.append(node)
                items.extend(node.childAtIndex(i) for i in range(node.childCount()))
            nodes = items
        return results[1:]

get_children(recursive: bool = False) -> list[QtQuick.QSGNode]

Get children of this item.

recursive option is written iteratively to also support original QTreeWidgetItems.

Source code in prettyqt/quick/sgnode.py
def get_children(self, recursive: bool = False) -> list[QtQuick.QSGNode]:
    """Get children of this item.

    recursive option is written iteratively to also support original QTreeWidgetItems.
    """
    if not recursive:
        return [self.childAtIndex(i) for i in range(self.childCount())]
    results = []
    nodes = [self]
    while nodes:
        items = []
        for node in nodes:
            results.append(node)
            items.extend(node.childAtIndex(i) for i in range(node.childCount()))
        nodes = items
    return results[1:]

get_type() -> NodeTypeStr

Get the type of the node.

Source code in prettyqt/quick/sgnode.py
def get_type(self) -> NodeTypeStr:
    """Get the type of the node.

    Returns:
        Node type
    """
    return NODE_TYPE.inverse[self.type()]

:fa-brands-github: Show source on GitHub