class QSGNode#

The QSGNode class is the base class for all nodes in the scene graph. More

Inherited by: QSGTransformNode, QSGTextNode, QSGRenderNode, QSGOpacityNode, QSGBasicGeometryNode, QSGGeometryNode, QSGSimpleTextureNode, QSGSimpleRectNode, QSGRectangleNode, QSGClipNode

Synopsis#

Methods#

Virtual methods#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

The QSGNode class can be used as a child container. Children are added with the appendChildNode() , prependChildNode() , insertChildNodeBefore() and insertChildNodeAfter() . The order of nodes is important as geometry nodes are rendered according to their ordering in the scene graph.

The scene graph nodes contain a mechanism that describes which parts of the scene have changed. This includes the combined matrices, accumulated opacity, changes to the node hierarchy, and so on. This information can be used for optimizations inside the scene graph renderer. For the renderer to properly render the nodes, it is important that users call markDirty() with the correct flags when nodes are changed. Most of the functions on the node classes will implicitly call markDirty() . For example, appendChildNode() will call markDirty() passing in DirtyNodeAdded .

If nodes change every frame, the preprocess() function can be used to apply changes to a node for every frame it is rendered. The use of preprocess() must be explicitly enabled by setting the UsePreprocess flag on the node.

The virtual isSubtreeBlocked() function can be used to disable a subtree all together. Nodes in a blocked subtree will not be preprocessed() and not rendered.

Note

All classes with QSG prefix should be used solely on the scene graph’s rendering thread. See Scene Graph and Rendering for more information.

class NodeType#

Can be used to figure out the type of node.

Constant

Description

QSGNode.BasicNodeType

The type of QSGNode

QSGNode.GeometryNodeType

The type of QSGGeometryNode

QSGNode.TransformNodeType

The type of QSGTransformNode

QSGNode.ClipNodeType

The type of QSGClipNode

QSGNode.OpacityNodeType

The type of QSGOpacityNode

QSGNode.RenderNodeType

The type of QSGRenderNode

See also

type()

class Flag#

(inherits enum.Flag) The QSGNode::Flag enum describes flags on the QSGNode

Constant

Description

QSGNode.OwnedByParent

The node is owned by its parent and will be deleted when the parent is deleted.

QSGNode.UsePreprocess

The node’s virtual preprocess() function will be called before rendering starts.

QSGNode.OwnsGeometry

Only valid for QSGGeometryNode and QSGClipNode . The node has ownership over the QSGGeometry instance and will delete it when the node is destroyed or a geometry is assigned.

QSGNode.OwnsMaterial

Only valid for QSGGeometryNode . The node has ownership over the material and will delete it when the node is destroyed or a material is assigned.

QSGNode.OwnsOpaqueMaterial

Only valid for QSGGeometryNode . The node has ownership over the opaque material and will delete it when the node is destroyed or a material is assigned.

QSGNode.InternalReserved

Reserved for internal use.

class DirtyStateBit#

(inherits enum.Flag) Used in markDirty() to indicate how the scene graph has changed.

Constant

Description

QSGNode.DirtyMatrix

The matrix in a QSGTransformNode has changed.

QSGNode.DirtyNodeAdded

A node was added.

QSGNode.DirtyNodeRemoved

A node was removed.

QSGNode.DirtyGeometry

The geometry of a QSGGeometryNode has changed.

QSGNode.DirtyMaterial

The material of a QSGGeometryNode has changed.

QSGNode.DirtyOpacity

The opacity of a QSGOpacityNode has changed.

QSGNode.DirtySubtreeBlocked

The subtree has been blocked.

See also

markDirty()

__init__(type)#
Parameters:

typeNodeType

__init__()

Constructs a new node

appendChildNode(node)#
Parameters:

nodeQSGNode

Appends node to this node’s list of children.

Ordering of nodes is important as geometry nodes will be rendered in the order they are added to the scene graph.

childAtIndex(i)#
Parameters:

i – int

Return type:

QSGNode

Returns the child at index i.

Children are stored internally as a linked list, so iterating over the children via the index is suboptimal.

childCount()#
Return type:

int

Returns the number of child nodes.

clearDirty()#

Note

This function is deprecated.

dirtyState()#
Return type:

Combination of DirtyStateBit

Note

This function is deprecated.

firstChild()#
Return type:

QSGNode

Returns the first child of this node.

The children are stored in a linked list.

flags()#
Return type:

Combination of Flag

Returns the set of flags for this node.

See also

setFlags()

insertChildNodeAfter(node, after)#
Parameters:

Inserts node to this node’s list of children after the node specified with after.

Ordering of nodes is important as geometry nodes will be rendered in the order they are added to the scene graph.

insertChildNodeBefore(node, before)#
Parameters:

Inserts node to this node’s list of children before the node specified with before.

Ordering of nodes is important as geometry nodes will be rendered in the order they are added to the scene graph.

isSubtreeBlocked()#
Return type:

bool

Returns whether this node and its subtree is available for use.

Blocked subtrees will not get their dirty states updated and they will not be rendered.

The QSGOpacityNode will return a blocked subtree when accumulated opacity is 0, for instance.

lastChild()#
Return type:

QSGNode

Returns the last child of this node.

The children are stored as a linked list.

markDirty(bits)#
Parameters:

bits – Combination of DirtyStateBit

Notifies all connected renderers that the node has dirty bits.

nextSibling()#
Return type:

QSGNode

Returns the node after this in the parent’s list of children.

The children are stored as a linked list.

parent()#
Return type:

QSGNode

Returns the parent node of this node.

prependChildNode(node)#
Parameters:

nodeQSGNode

Prepends node to this node’s the list of children.

Ordering of nodes is important as geometry nodes will be rendered in the order they are added to the scene graph.

preprocess()#

Override this function to do processing on the node before it is rendered.

Preprocessing needs to be explicitly enabled by setting the flag UsePreprocess . The flag needs to be set before the node is added to the scene graph and will cause the preprocess() function to be called for every frame the node is rendered.

Warning

Beware of deleting nodes while they are being preprocessed. It is possible, with a small performance hit, to delete a single node during its own preprocess call. Deleting a subtree which has nodes that also use preprocessing may result in a segmentation fault. This is done for performance reasons.

previousSibling()#
Return type:

QSGNode

Returns the node before this in the parent’s list of children.

The children are stored as a linked list.

removeAllChildNodes()#

Removes all child nodes from this node’s list of children.

removeChildNode(node)#
Parameters:

nodeQSGNode

Removes node from this node’s list of children.

reparentChildNodesTo(newParent)#
Parameters:

newParentQSGNode

setFlag(arg__1[, arg__2=true])#
Parameters:
  • arg__1Flag

  • arg__2 – bool

Sets the flag f on this node if enabled is true; otherwise clears the flag.

See also

flags()

setFlags(arg__1[, arg__2=true])#
Parameters:
  • arg__1 – Combination of Flag

  • arg__2 – bool

Sets the flags f on this node if enabled is true; otherwise clears the flags.

See also

flags()

type()#
Return type:

NodeType

Returns the type of this node. The node type must be one of the predefined types defined in NodeType and can safely be used to cast to the corresponding class.