本页内容

QSGClipNode Class

QSGClipNode 类实现了场景图中的裁剪功能。更多内容...

头文件: #include <QSGClipNode>
CMake: find_package(Qt6 REQUIRED COMPONENTS Quick)
target_link_libraries(mytarget PRIVATE Qt6::Quick)
qmake: QT += quick
继承自: QSGBasicGeometryNode

公共函数

QSGClipNode()
virtual ~QSGClipNode() override
QRectF clipRect() const
bool isRectangular() const
void setClipRect(const QRectF &rect)
void setIsRectangular(bool rectHint)

详细描述

裁剪操作适用于该节点的子树,并且可以嵌套。多个裁剪节点将通过其所有几何体的相交来累加。该累加过程作为渲染的一部分进行。

剪裁节点必须具有几何体,才能添加到场景图中。

裁剪通常通过使用模板缓冲区来实现。

注意:所有 以 QSG 为前缀的类应仅在场景图的渲染线程上使用。更多信息请参阅《场景图与渲染》。

成员函数文档

QSGClipNode::QSGClipNode()

创建一个不包含几何体的新的 QSGClipNode。

剪切节点必须先拥有几何体,才能被添加到场景图中。

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

删除该QSGClipNode 。

如果启用了QSGNode::OwnsGeometry 标志,几何体也将被删除。

QRectF QSGClipNode::clipRect() const

返回该节点的裁剪矩形。

另请参阅 setClipRect()。

bool QSGClipNode::isRectangular() const

如果该剪切节点具有矩形剪切区域,则返回。

另请参阅 setIsRectangular()。

void QSGClipNode::setClipRect(const QRectF &rect)

将此剪切节点的剪切矩形设置为rect 。

当设置矩形裁剪区域并结合setIsRectangular 使用时,渲染器在某些情况下可能会采用更优的裁剪方法。

另请参阅 clipRect()。

void QSGClipNode::setIsRectangular(bool rectHint)

将此剪切节点的矩形剪切范围设置为rectHint 。

这是一个优化提示,表示渲染器可以使用剪切法代替模板法,前者速度显著更快。

当设置此提示且其适用时,裁剪区域将由 `clipRect()` 生成,而非 `geometry()`。

默认情况下,此属性为false 。

另请参阅 isRectangular()。

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