QGraphicsPolygonItem Class
La clase `QGraphicsPolygonItem` proporciona un elemento poligonal que se puede añadir a un ` QGraphicsScene`. Más información...
| Encabezado: | #include <QGraphicsPolygonItem> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| Heredado de: | 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 objeto ` QPolygonF ` al constructor de `QGraphicsPolygonItem` o llama a la función ` setPolygon()`. La función ` polygon()` devuelve el polígono actual.

QGraphicsPolygonItem utiliza el polígono y el grosor del trazo para proporcionar una implementación adecuada de las funciones boundingRect(), shape() y contains(). La función paint() dibuja el polígono utilizando el trazo y el pincel asociados al elemento, que se pueden configurar llamando a las funciones setPen() y setBrush().
Véase también « QGraphicsPathItem» , « QGraphicsRectItem », « QGraphicsEllipseItem », « QGraphicsTextItem », « QGraphicsLineItem », « QGraphicsPixmapItem » y «Graphics View Framework».
Documentación sobre los tipos de miembro
[anonymous] enum
El valor devuelto por la función virtual type().
| Constante | Valor | Descripción |
|---|---|---|
QGraphicsPolygonItem::Type | 5 | Un elemento poligonal gráfico |
Documentación de la función miembro
[explicit] QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent = nullptr)
Crea un objeto `QGraphicsPolygonItem`. Se pasa ` parent ` al constructor de ` QAbstractGraphicsShapeItem`.
Véase también QGraphicsScene::addItem().
[explicit] QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon, QGraphicsItem *parent = nullptr)
Crea un objeto `QGraphicsPolygonItem` con ` polygon ` como polígono predeterminado. El objeto ` parent ` se pasa al constructor de ` QAbstractGraphicsShapeItem`.
Véase 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 predeterminada 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 predeterminada es « Qt::OddEvenFill ».
Véanse también fillRule(), QPainterPath::fillRule() y QPainter::drawPolygon().
void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon)
Establece el polígono del elemento como el polygon indicado.
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.