QGraphicsPathItem Class
QGraphicsPathItem 类提供了一个路径项,您可以将其添加到QGraphicsScene... 更多...
头文件: | #include <QGraphicsPathItem> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
继承: | QAbstractGraphicsShapeItem |
公共类型
enum | anonymous { Type } |
公共函数
QGraphicsPathItem(QGraphicsItem *parent = nullptr) | |
QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = nullptr) | |
virtual | ~QGraphicsPathItem() |
QPainterPath | path() const |
void | setPath(const QPainterPath &path) |
重新实现的公共函数
virtual QRectF | boundingRect() const override |
virtual bool | contains(const QPointF &point) const override |
virtual bool | isObscuredBy(const QGraphicsItem *item) const override |
virtual QPainterPath | opaqueArea() const override |
virtual void | paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override |
virtual QPainterPath | shape() const override |
virtual int | type() const override |
详细说明
要设置项目的路径,请向 QGraphicsPathItem 的构造函数传递QPainterPath 或调用setPath() 函数。path() 函数返回当前路径。
QGraphicsPathItem 使用该路径提供了boundingRect(),shape(), 和contains() 的合理实现。paint() 函数使用项目的关联笔和笔刷绘制路径,您可以通过调用setPen() 和setBrush() 函数设置笔和笔刷。
另请参阅 QGraphicsRectItem,QGraphicsEllipseItem,QGraphicsPolygonItem,QGraphicsTextItem,QGraphicsLineItem,QGraphicsPixmapItem 和图形视图框架。
成员函数文档
[explicit]
QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent = nullptr)
构造一个 QGraphicsPath。parent 传递给QAbstractGraphicsShapeItem 的构造函数。
另请参见 QGraphicsScene::addItem().
[explicit]
QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = nullptr)
使用path 作为默认路径构造 QGraphicsPath 项目。parent 将传递给QAbstractGraphicsShapeItem 的构造函数。
另请参阅 QGraphicsScene::addItem().
[virtual noexcept]
QGraphicsPathItem::~QGraphicsPathItem()
[override virtual]
QRectF QGraphicsPathItem::boundingRect() const
重实现:QGraphicsItem::boundingRect() const.
[override virtual]
bool QGraphicsPathItem::contains(const QPointF &point) const
重实现:QGraphicsItem::contains(const QPointF &point) const.
[override virtual]
bool QGraphicsPathItem::isObscuredBy(const QGraphicsItem *item) const
重实现:QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const.
[override virtual]
QPainterPath QGraphicsPathItem::opaqueArea() const
重实现:QAbstractGraphicsShapeItem::opaqueArea() const.
[override virtual]
void QGraphicsPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr)
重实现:QGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)。
QPainterPath QGraphicsPathItem::path() const
以QPainterPath 的形式返回项目的路径。如果没有设置项目,则返回空的QPainterPath 。
另请参阅 setPath() 。
void QGraphicsPathItem::setPath(const QPainterPath &path)
设置项目的路径为给定的path 。
另请参阅 path() 。
[override virtual]
QPainterPath QGraphicsPathItem::shape() const
重实现:QGraphicsItem::shape() const.
[override virtual]
int QGraphicsPathItem::type() const
重实现:QGraphicsItem::type() const.
© 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.