QAbstractGraphicsShapeItem Class

QAbstractGraphicsShapeItem 类为所有路径项提供了一个通用基础。更多

Header: #include <QAbstractGraphicsShapeItem>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
继承: QGraphicsItem
继承者:

QGraphicsEllipseItem,QGraphicsPathItem,QGraphicsPolygonItem,QGraphicsRectItem, 以及QGraphicsSimpleTextItem

公共函数

QAbstractGraphicsShapeItem(QGraphicsItem *parent = nullptr)
virtual ~QAbstractGraphicsShapeItem()
QBrush brush() const
QPen pen() const
void setBrush(const QBrush &brush)
void setPen(const QPen &pen)

重新实现的公共函数

virtual bool isObscuredBy(const QGraphicsItem *item) const override
virtual QPainterPath opaqueArea() const override

详细说明

该类本身并没有完全实现一个项目;特别是,它没有实现QGraphicsItem 继承的boundingRect() 和paint() 。

您可以子类化该项目,为项目的钢笔和画笔提供一个简单的基本访问器实现。

另请参阅 QGraphicsRectItem,QGraphicsEllipseItem,QGraphicsPathItem,QGraphicsPolygonItem,QGraphicsTextItem,QGraphicsLineItem,QGraphicsPixmapItem图形视图框架

成员函数文档

[explicit] QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QGraphicsItem *parent = nullptr)

构造一个 QAbstractGraphicsShapeItem。parent 传递给QGraphicsItem 的构造函数。

[virtual noexcept] QAbstractGraphicsShapeItem::~QAbstractGraphicsShapeItem()

销毁QAbstractGraphicsShapeItem.

QBrush QAbstractGraphicsShapeItem::brush() const

返回项目的笔刷,如果未设置笔刷,则返回空笔刷。

另请参阅 setBrush()。

[override virtual] bool QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const

重实现:QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const.

[override virtual] QPainterPath QAbstractGraphicsShapeItem::opaqueArea() const

重实现:QGraphicsItem::opaqueArea() const.

QPen QAbstractGraphicsShapeItem::pen() const

返回项目的笔。如果没有设置笔,该函数将返回 QPen(),即默认的宽度为 1 的黑色实线钢笔。

另请参见 setPen()。

void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush)

将项目的笔刷设置为brush

项目的笔刷用于填充项目。

如果使用带有QGradient 的笔刷,梯度是相对于项目坐标系的。

另请参阅 brush().

void QAbstractGraphicsShapeItem::setPen(const QPen &pen)

将此项目的钢笔设置为pen

钢笔用于绘制项目的轮廓。

另请参阅 pen()。

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