En esta página

QGraphicsPolygonItem Class

La clase QGraphicsPolygonItem proporciona un elemento de polígono que se puede añadir a un QGraphicsScene. Más...

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

Tipos Públicos

enum { Type }

Funciones Públicas

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)

Funciones Públicas Reimplementadas

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

Descripción Detallada

Para establecer el polígono del elemento, pasa un QPolygonF al constructor de QGraphicsPolygonItem, o llama a la función setPolygon(). La función polygon() devuelve el polígono actual.

Polígono dibujado cerca del origen

QGraphicsPolygonItem utiliza el polígono y el ancho del lápiz para proporcionar una implementación razonable de boundingRect(), shape(), y contains(). La función paint() dibuja el polígono usando el lápiz y el pincel asociados al ítem, que puedes establecer llamando a las funciones setPen() y setBrush().

Ver también QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, y Graphics View Framework.

Documentación de tipos de miembros

[anonymous] enum

El valor devuelto por la función virtual type().

ConstanteValorDescripción
QGraphicsPolygonItem::Type5Un polígono gráfico

Documentación de la función miembro

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

Construye un QGraphicsPolygonItem. parent se pasa al constructor de QAbstractGraphicsShapeItem.

Ver también QGraphicsScene::addItem().

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

Construye un QGraphicsPolygonItem con polygon como polígono por defecto. parent se pasa al constructor de QAbstractGraphicsShapeItem.

Ver también QGraphicsScene::addItem().

[virtual noexcept] QGraphicsPolygonItem::~QGraphicsPolygonItem()

Destruye el QGraphicsPolygonItem.

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

Reimplementa: QGraphicsItem::boundingRect() const.

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

Reimplementa: QGraphicsItem::contains(const QPointF &point) const.

Qt::FillRule QGraphicsPolygonItem::fillRule() const

Devuelve la regla de relleno del polígono. La regla de relleno por defecto es Qt::OddEvenFill.

Véase también setFillRule(), QPainterPath::fillRule() y QPainter::drawPolygon().

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

Reimplementa: QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const.

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

Reimplementa: QAbstractGraphicsShapeItem::opaqueArea() const.

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

Reimplementa: QGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget).

QPolygonF QGraphicsPolygonItem::polygon() const

Devuelve el polígono del elemento, o un polígono vacío si no se ha establecido ningún polígono.

Véase también setPolygon().

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

Establece la regla de relleno del polígono en rule. La regla de relleno por defecto es Qt::OddEvenFill.

Véase también fillRule(), QPainterPath::fillRule(), y QPainter::drawPolygon().

void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon)

Define el polígono del elemento como polygon.

Véase también polygon().

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

Reimplementa: QGraphicsItem::shape() const.

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

Reimplementa: QGraphicsItem::type() const.

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