Qt3DCore::QNode Class

class Qt3DCore::QNode

QNode 是用于构建 Qt3D 场景的所有 Qt3D 节点类的基类。更多

属性

公共功能

QNode(Qt3DCore::QNode *parent = nullptr)
bool blockNotifications(bool block)
Qt3DCore::QNodeVector childNodes() const
Qt3DCore::QNodeId id() const
bool isEnabled() const
bool notificationsBlocked() const
Qt3DCore::QNode *parentNode() const

公共插槽

void setEnabled(bool isEnabled)
void setParent(Qt3DCore::QNode *parent)

信号

void enabledChanged(bool enabled)
void nodeDestroyed()
void parentChanged(QObject *parent)
QNodePtr
QNodeVector
Qt3DCore::QNodeId qIdForNode(Qt3DCore::QNode *node)
Qt3DCore::QNodeIdVector qIdsForNodes(const T &nodes)

详细说明

QNode 的属性由QObject 节点之间的父/子关系决定。QNode 本身没有视觉外观,也没有特定的含义,它是构建基于节点的树形结构的一种方式。

QNode 实例的父节点只能是另一个 QNode 实例。

每个 QNode 实例都有一个唯一的 ID,以便从其他实例中识别出来。

在 QNode 子类上定义属性后,其 NOTIFY 信号将自动生成 Qt3D 后端将收到的通知。

另请参阅 QEntityQComponent

属性文档

enabled : bool

持有QNode 启用标志。默认情况下,QNode 总是启用的。

注意: 启用的含义取决于方面的解释。即使启用设置为false ,某些方面仍可能以某种方式考虑该节点。这将按类逐一记录。

访问功能:

bool isEnabled() const
void setEnabled(bool isEnabled)

通知信号:

void enabledChanged(bool enabled)

parent : Qt3DCore::QNode*

保存QNode 的直接父节点,如果节点没有父节点,则保存为空。

设置父节点将通知后台有关当前QNode 实例父节点变更的信息。

注意: 如果parent 恰好为空,则实际上会通知当前QNode 实例已从场景中删除。

访问功能:

Qt3DCore::QNode *parentNode() const
void setParent(Qt3DCore::QNode *parent)

Notifier 信号:

void parentChanged(QObject *parent)

成员函数 文档

[explicit] QNode::QNode(Qt3DCore::QNode *parent = nullptr)

创建一个新的 QNode 实例,其父节点为parent

注意: 只有当 QNode 实例有父节点时,后端才会收到通知,说明该 QNode 实例是场景的一部分;除非该 QNode 实例是 Qt3D 场景的根节点。

另请参阅 setParent() 。

bool QNode::blockNotifications(bool block)

如果blocktrue ,则会阻止该对象向各个方面发送属性更改通知。如果blockfalse ,则不会发生此类阻塞。

返回值是notificationsBlocked() 之前的值。

请注意,即使此对象的通知已被阻止,其他通知类型仍会发送。

另请参见 notificationsBlocked()。

Qt3DCore::QNodeVector QNode::childNodes() const

返回一个列表,其中包含当前QNode 实例的QNode 子目录。

Qt3DCore::QNodeId QNode::id() const

返回唯一标识QNode 实例的 id。

[signal] void QNode::nodeDestroyed()

节点销毁时发出。

bool QNode::notificationsBlocked() const

如果方面通知被阻止,则返回true ;否则返回false 。默认情况下,通知不会被阻止。

另请参阅 blockNotifications() 。

相关非会员

[alias] QNodePtr

QNode 的共享指针。

[alias] QNodeVector

QNode 指针列表。

Qt3DCore::QNodeId qIdForNode(Qt3DCore::QNode *node)

返回node 的节点 ID。

template <typename T> Qt3DCore::QNodeIdVector qIdsForNodes(const T &nodes)

返回nodes 的节点 ID 向量。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.