QGraphicsPolygonItem 类

QGraphicsPolygonItem 类提供的多边形项可以被添加到 QGraphicsScene . 更多...

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

公共类型

enum anonymous { Type }

公共函数

QGraphicsPolygonItem (QGraphicsItem * parent = nullptr)
QGraphicsPolygonItem (const QPolygonF & polygon , QGraphicsItem * parent = nullptr)
virtual ~QGraphicsPolygonItem ()
Qt::FillRule fillRule () const
QPolygonF polygon () const
void setFillRule (Qt::FillRule rule )
void setPolygon (const QPolygonF & polygon )

重实现公共函数

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

详细描述

要设置项的多边形,传递 QPolygonF 到 QGraphicsPolygonItem 的构造函数,或调用 setPolygon () 函数。 polygon () 函数返回当前多边形。

QGraphicsPolygonItem uses the polygon and the pen width to provide a reasonable implementation of boundingRect (), shape (),和 contains ()。 paint () function draws the polygon using the item's associated pen and brush, which you can set by calling the setPen () 和 setBrush () 函数。

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

成员类型文档编制

enum QGraphicsPolygonItem:: anonymous

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

常量 描述
QGraphicsPolygonItem::Type 5 A graphics polygon item

成员函数文档编制

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

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

另请参阅 QGraphicsScene::addItem ().

[explicit] QGraphicsPolygonItem:: QGraphicsPolygonItem (const QPolygonF & polygon , QGraphicsItem * parent = nullptr)

构造 QGraphicsPolygonItem 采用 polygon 作为默认多边形。 parent 会被传递给 QAbstractGraphicsShapeItem 的构造函数。

另请参阅 QGraphicsScene::addItem ().

[virtual noexcept] QGraphicsPolygonItem:: ~QGraphicsPolygonItem ()

销毁 QGraphicsPolygonItem .

[override virtual] QRectF QGraphicsPolygonItem:: boundingRect () const

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

[override virtual] bool QGraphicsPolygonItem:: contains (const QPointF & point ) const

重实现: QGraphicsItem::contains(const QPointF &point) const .

Qt::FillRule QGraphicsPolygonItem:: fillRule () const

返回多边形填充规则。默认填充规则为 Qt::OddEvenFill .

另请参阅 setFillRule (), QPainterPath::fillRule (),和 QPainter::drawPolygon ().

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

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

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

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

[override virtual] void QGraphicsPolygonItem:: paint ( QPainter * painter , const QStyleOptionGraphicsItem * option , QWidget * widget = nullptr)

重实现: QGraphicsItem::paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget).

QPolygonF QGraphicsPolygonItem:: polygon () const

Returns the item's polygon, or an empty polygon if no polygon has been set.

另请参阅 setPolygon ().

void QGraphicsPolygonItem:: setFillRule ( Qt::FillRule rule )

Sets the fill rule of the polygon to rule . The default fill rule is Qt::OddEvenFill .

另请参阅 fillRule (), QPainterPath::fillRule (),和 QPainter::drawPolygon ().

void QGraphicsPolygonItem:: setPolygon (const QPolygonF & polygon )

将项的多边形设为给定 polygon .

另请参阅 polygon ().

[override virtual] QPainterPath QGraphicsPolygonItem:: shape () const

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

[override virtual] int QGraphicsPolygonItem:: type () const

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