QNode Class | Qt3D Module 5.5

- Qt 5.5
- Qt3D Module
- C++ Classes
- QNode
- Qt 5.5.1 Reference Documentation

# QNode Class

(Qt3D::QNode)

Qt3D::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
Inherits: | QObject
Inherited By: | Qt3D::QComponent, Qt3D::QEntity, Qt3D::QKeyboardController, and Qt3D::QMouseController

- List of all members, including inherited members

## Properties

- parent : Qt3D::QNode *

- 1 property inherited from QObject

## Public Functions

| QNode(QNode * parent = 0)
virtual | ~QNode()
bool | blockNotifications(bool block)
QNodeList | childrenNodes() const
const QNodeId | id() const
bool | notificationsBlocked() const
QNode * | parentNode() const
virtual void | setParent(QNode * parent)

- 31 public functions inherited from QObject

## Signals

void | parentChanged()

- 2 signals inherited from QObject

## Protected Functions

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

- 9 protected functions inherited from QObject

## Static Protected Members

QNode * | clone(QNode * node)

### Additional Inherited Members

- 1 public slot inherited from QObject
- 1 public variable inherited from QObject
- 10 static public members inherited from QObject
- 2 protected variables inherited from QObject

## Detailed Description

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

The owernship of Qt3D::QNode is determined by the QObject parent/child relationship between nodes. By itself a Qt3D::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 Qt3D::QNode instance can only be another Qt3D::QNode instance.

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

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

When subclassing Qt3D::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 Qt3D::QNode subclass instance is eventually destroyed.

See also Qt3D::QEntity and Qt3D::QComponent.

## Property Documentation

### parent : Qt3D::QNode *

Access functions:

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

Notifier signal:

void | parentChanged()

## Member Function Documentation

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

Creates a new Qt3D::QNode instance with parent parent.

Note: The backend aspects will be notified that a Qt3D::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(Qt3D::QNode *).

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

### 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 Qt3D::QNode children of the current Qt3D::QNode instance.

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

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

Note: It must be called by the destructor of every class subclassing Qt3D::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 Qt3D::QNode instance.

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

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

Returns the id that uniquely identifies the Qt3D::QNode instance.

### bool QNode::notificationsBlocked() const

Returns `true` if aspect notifications are blocked; otherwise returns `false`. Notifications are not blocked by default.

See also blockNotifications().

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

Called when one or more backend aspects sends a notification change to the current Qt3D::QNode instance.

Note: This method should be reimplemented in your subclasses to properly handle the change.