Qt 5.6 | Qt 3D | C++ Classes | QNode

Qt 5.6.3 Reference Documentation

# QNode Class

(Qt3DCore::QNode)

QNode is the base class of all Qt3D node classes used to build a Qt3D scene. More...

Header: | #include <QNode>
qmake: | QT += 3dcore
Since: | Qt 5.5

Inherited By:

Qt3DCore::QComponent, Qt3DCore::QEntity, Qt3DInput::QAbstractPhysicalDevice, Qt3DInput::QAction, Qt3DInput::QActionInput, Qt3DInput::QAxis, Qt3DInput::QAxisInput, Qt3DInput::QAxisSetting, Qt3DInput::QLogicalDevice, Qt3DRender::QAbstractAttribute, Qt3DRender::QAbstractBuffer, Qt3DRender::QAbstractTextureImage, Qt3DRender::QAbstractTextureProvider, Qt3DRender::QAnnotation, Qt3DRender::QFrameGraphNode, Qt3DRender::QGeometry, and Qt3DRender::QParameterMapping

- List of all members, including inherited members

## Properties

- enabled : bool
- parent : Qt3DCore::QNode *

## Public Functions

| QNode(QNode *parent = Q_NULLPTR)
virtual | ~QNode()
bool | blockNotifications(bool block)
QNodeList | childrenNodes() const
const QNodeId | id() const
bool | isEnabled() const
bool | notificationsBlocked() const
QNode * | parentNode() const

## Public Slots

void | setEnabled(bool isEnabled)
virtual void | setParent(QNode *parent)

## Signals

void | enabledChanged(bool enabled)
void | parentChanged(QObject *parent)

## Protected Functions

void | cleanup()
virtual void | copy(const QNode *ref)
virtual void | sceneChangeEvent(const QSceneChangePtr &change)

## Static Protected Members

QNode * | clone(QNode *node)

## Related Non-Members

typedef | QNodeList
typedef | QNodePtr

## Detailed Description

QNode is the base class of all Qt3D node classes used to build a Qt3D scene.

The owernship of QNode is determined by the QObject parent/child relationship between nodes. By itself, a QNode has no visual appearance and no particular meaning, it is there as a way of building a node based tree structure.

The parent of a QNode instance can only be another QNode instance.

Each QNode instance has a unique id that allows it to be recognizable from other instances.

When properties are defined on a QNode subclass, their NOTIFY signal will automatically generate notifications that the Qt3D backend aspects will receive.

When subclassing QNode, make sure to call QNode::cleanup() from your subclass's destructor to ensure proper notification to backend aspects. Faiure to do so will result in crashes when one of your QNode subclass instance is eventually destroyed.

See also QEntity and QComponent.

## Property Documentation

### enabled : bool

Access functions:

bool | isEnabled() const
void | setEnabled(bool isEnabled)

Notifier signal:

void | enabledChanged(bool enabled)

### parent : Qt3DCore::QNode *

Access functions:

QNode * | parentNode() const
virtual void | setParent(QNode *parent)

Notifier signal:

void | parentChanged(QObject *parent)

## Member Function Documentation

### QNode::QNode(QNode *parent = Q_NULLPTR)

Creates a new QNode instance with parent parent.

Note: The backend aspects will be notified that a QNode instance is part of the scene only if it has a parent; unless this is the root node of the Qt3D scene.

See also setParent().

### `[virtual]` QNode::~QNode()

Destroys the instance of QNode. The destructor is virtual.

### bool QNode::blockNotifications(bool block)

If block is `true`, property change notifications sent by this object to aspects are blocked. If block is `false`, no such blocking will occur.

The return value is the previous value of notificationsBlocked().

Note that the other notification types will be sent even if the notifications for this object have been blocked.

See also notificationsBlocked().

### QNodeList QNode::childrenNodes() const

Returns a list filled with the QNode children of the current QNode instance.

### `[protected]` void QNode::cleanup()

This methods can only be called once and takes care of notyfing the backend aspects that the current Qt3DCore::QNode instance is about to be destroyed.

Note: It must be called by the destructor of every class subclassing QNode that is clonable (using the QT3D_CLONEABLE macro).

### `[static protected]` QNode *QNode::clone(QNode *node)

Returns a clone of node. All the children of node are cloned as well.

Note: This is the only way to create two nodes with the same id.

### `[virtual protected]` void QNode::copy(const QNode *ref)

Copies all the attributes from ref to the current Qt3DCore::QNode instance.

Note: When subclassing QNode, you should reimplement this method and always call the copy method on the base class. This will ensure that when cloned, the QNode is properly initialized.

### const QNodeId QNode::id() const

Returns the id that uniquely identifies the QNode instance.

### bool QNode::isEnabled() const

Returns whether the QNode is enabled or not.

Note: Getter function for property enabled.

### bool QNode::notificationsBlocked() const

Returns `true` if aspect notifications are blocked; otherwise returns `false`. By default, notifications are not blocked.

See also blockNotifications().

### QNode *QNode::parentNode() const

Returns the immediate QNode parent, or null if the node has no parent.

Note: Getter function for property parent.

### `[virtual protected]` void QNode::sceneChangeEvent(const QSceneChangePtr &change)

### `[slot]` void QNode::setEnabled(bool isEnabled)

Set the QNode to enabled if isEnabled is `true`. By default a QNode is always enabled.

Note: the interpretation of what enabled means is aspect-dependent. Even if enabled is set to `false`, some aspects may still consider the node in some manner. This is documented on a class by class basis.

Note: Setter function for property enabled.

See also isEnabled().

### `[virtual slot]` void QNode::setParent(QNode *parent)

Sets the parent node of the current QNode instance to parent. Setting the parent will notify the backend aspects about current QNode instance's parent change.

Note: if parent happens to be null, this will actually notify that the current QNode instance was removed from the scene.

Note: Setter function for property parent.

## Related Non-Members

### typedef Qt3DCore::QNodeList

List of QNode pointers.

### typedef Qt3DCore::QNodePtr

A shared pointer for QNode.