QAbstractGraphicsShapeItem Class
QAbstractGraphicsShapeItem 类为所有路径项提供了一个通用的基类。更多内容...
| 头文件: | #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 |
详细说明
此类本身并未完全实现一个项目;特别是,它未实现boundingRect() 和paint(),这些方法由QGraphicsItem 继承。
您可以派生此项的子类,为该项的笔和画笔提供简单的访问器基实现。
另请参阅 QGraphicsRectItem 、QGraphicsEllipseItem 、QGraphicsPathItem 、QGraphicsPolygonItem 、QGraphicsTextItem 、QGraphicsLineItem 、QGraphicsPixmapItem 以及Graphics View Framework。
成员函数文档
[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()。
© 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.