QGraphicsPathItem 类

QGraphicsPathItem 类提供的路径项可以被添加到 QGraphicsScene . 更多...

头: #include <QGraphicsPathItem>
qmake: QT += widgets
Since: Qt 4.2
继承: QAbstractGraphicsShapeItem

该类在 Qt 4.2 引入。

公共类型

enum anonymous { Type }

公共函数

QGraphicsPathItem (const QPainterPath & path , QGraphicsItem * parent = nullptr)
QGraphicsPathItem (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

详细描述

要设置项的路径,传递 QPainterPath 给 QGraphicsPathItem 的构造函数,或调用 setPath () 函数。 path () 函数返回当前路径。

QGraphicsPathItem 使用路径以提供合理实现的 boundingRect (), shape (),和 contains ()。 paint () 函数使用项关联的钢笔和笔刷绘制路径,可以设置通过调用 setPen () 和 setBrush () 函数。

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

成员类型文档编制

enum QGraphicsPathItem:: anonymous

值的返回通过虚拟 type () 函数。

常量 描述
QGraphicsPathItem::Type 2 图形路径项

成员函数文档编制

QGraphicsPathItem:: QGraphicsPathItem (const QPainterPath & path , QGraphicsItem * parent = nullptr)

构造 QGraphicsPath 项使用 path 作为默认路径。 parent 会被传递给 QAbstractGraphicsShapeItem 的构造函数。

另请参阅 QGraphicsScene::addItem ().

QGraphicsPathItem:: QGraphicsPathItem ( QGraphicsItem * parent = nullptr)

构造 QGraphicsPath。 parent 会被传递给 QAbstractGraphicsShapeItem 的构造函数。

另请参阅 QGraphicsScene::addItem ().

[virtual] QGraphicsPathItem:: ~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.