QSGSimpleRectNode Class

QSGSimpleRectNode 类是使用场景图绘制实心填充矩形的方便类。更多

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

公共函数

QSGSimpleRectNode()
QSGSimpleRectNode(const QRectF &rect, const QColor &color)
QColor color() const
QRectF rect() const
void setColor(const QColor &color)
void setRect(const QRectF &rect)
void setRect(qreal x, qreal y, qreal w, qreal h)

详细说明

警告: 本实用工具类仅在运行Qt Quick 场景图的默认或软件后端时有效。作为替代方案,请通过QQuickWindow::createRectangleNode() 使用QSGRectangleNode 。不过,当通过子类化使用且应用程序知道不会涉及特殊场景图后端时,该独立类仍然有用。

成员函数文档

QSGSimpleRectNode::QSGSimpleRectNode()

构造一个空矩形和白色的 QSGSimpleRectNode 实例。

QSGSimpleRectNode::QSGSimpleRectNode(const QRectF &rect, const QColor &color)

构建一个 QSGSimpleRectNode 实例,该实例的跨度为rect ,颜色为color

QColor QSGSimpleRectNode::color() const

返回此矩形的颜色。

另请参阅 setColor()。

QRectF QSGSimpleRectNode::rect() const

返回此矩形节点覆盖的矩形区域。

另请参阅 setRect()。

void QSGSimpleRectNode::setColor(const QColor &color)

将此矩形的颜色设置为color 。默认颜色为白色。

另请参阅 color().

void QSGSimpleRectNode::setRect(const QRectF &rect)

将此 rect 节点的矩形设置为rect

另请参见 rect()。

void QSGSimpleRectNode::setRect(qreal x, qreal y, qreal w, qreal h)

这是一个重载函数。

设置此矩形节点的矩形以 (x,y) 为起点,宽度为w ,高度为h

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