QSGOpacityNode Class

QSGOpacityNode 类用于改变节点的不透明度。更多

Header: #include <QSGOpacityNode>
CMake: find_package(Qt6 REQUIRED COMPONENTS Quick)
target_link_libraries(mytarget PRIVATE Qt6::Quick)
qmake: QT += quick
继承: QSGNode

公共函数

QSGOpacityNode()
virtual ~QSGOpacityNode() override
qreal opacity() const
void setOpacity(qreal opacity)

详细说明

不透明度适用于其子树并可嵌套。多个不透明度节点的不透明度将通过相乘的方式累加。累积是渲染的一部分。

当嵌套的不透明度低于某个阈值时,子树可能会被标记为阻塞,导致isSubtreeBlocked() 返回 true。这样做是出于性能考虑。

注意: 所有带有 QSG 前缀的类都只能在场景图的渲染线程中使用。更多信息请参阅场景图和渲染

成员函数文档

QSGOpacityNode::QSGOpacityNode()

构建一个不透明度节点,默认不透明度为 1。

不透明度在场景图中会向下累积,因此一个节点的上方有两个不透明度均为 0.5 的 QSGOpacityNode 实例,则该节点的有效不透明度为 0.25。

节点的默认不透明度为 1。

[override virtual noexcept] QSGOpacityNode::~QSGOpacityNode()

删除不透明度节点。

qreal QSGOpacityNode::opacity() const

返回此不透明度节点的不透明度。

另请参阅 setOpacity()。

void QSGOpacityNode::setOpacity(qreal opacity)

将此节点的不透明度设置为opacity

在渲染图形之前,渲染器会对子树进行一次更新,将不透明度传播给其子节点。

该值的范围为 0 至 1。

另请参见 opacity()。

© 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.