Auf dieser Seite

QGraphicsPolygonItem Class

Die Klasse „QGraphicsPolygonItem“ stellt ein Polygon-Element bereit, das Sie einem „ QGraphicsScene “ hinzufügen können. Mehr...

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

Öffentliche Typen

enum { Type }

Öffentliche Funktionen

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)

Neu implementierte öffentliche Funktionen

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

Ausführliche Beschreibung

Um das Polygon des Elements festzulegen, übergeben Sie ein ` QPolygonF ` an den Konstruktor von `QGraphicsPolygonItem` oder rufen Sie die Funktion ` setPolygon()` auf. Die Funktion ` polygon()` gibt das aktuelle Polygon zurück.

In der Nähe des Ursprungs gezeichnetes Vieleck

QGraphicsPolygonItem verwendet das Polygon und die Stiftbreite, um eine sinnvolle Implementierung von ` boundingRect()`, ` shape()` und ` contains()` bereitzustellen. Die Funktion ` paint()` zeichnet das Polygon mit dem dem Element zugeordneten Stift und Pinsel, die Sie durch Aufruf der Funktionen ` setPen()` und ` setBrush()` festlegen können.

Siehe auch „ QGraphicsPathItem“ , „ QGraphicsRectItem “, „ QGraphicsEllipseItem “, „ QGraphicsTextItem “, „ QGraphicsLineItem “, „ QGraphicsPixmapItem “ und „Graphics View Framework“.

Dokumentation zu Mitgliedstypen

[anonymous] enum

Der von der virtuellen Funktion ` type()` zurückgegebene Wert.

KonstanteWertBeschreibung
QGraphicsPolygonItem::Type5Ein Grafik-Polygon-Element

Dokumentation der Mitgliedsfunktionen

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

Erstellt ein `QGraphicsPolygonItem`. ` parent ` wird an den Konstruktor von ` QAbstractGraphicsShapeItem` übergeben.

Siehe auch QGraphicsScene::addItem().

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

Erstellt ein `QGraphicsPolygonItem` mit ` polygon ` als Standardpolygon. ` parent ` wird an den Konstruktor von ` QAbstractGraphicsShapeItem` übergeben.

Siehe auch „ QGraphicsScene::addItem()“.

[virtual noexcept] QGraphicsPolygonItem::~QGraphicsPolygonItem()

Zerstört den „ QGraphicsPolygonItem “.

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

Implementiert: ` QGraphicsItem::boundingRect()` const.

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

Implementiert neu: ` QGraphicsItem::contains(const QPointF &point) const`.

Qt::FillRule QGraphicsPolygonItem::fillRule() const

Gibt die Füllregel des Polygons zurück. Die Standard-Füllregel lautet „ Qt::OddEvenFill “.

Siehe auch „ setFillRule()“, „ QPainterPath::fillRule()“ und „ QPainter::drawPolygon()“.

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

Implementiert erneut: ` QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const`.

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

Implementiert: ` QAbstractGraphicsShapeItem::opaqueArea()` const.

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

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

QPolygonF QGraphicsPolygonItem::polygon() const

Gibt das Polygon des Elements zurück oder ein leeres Polygon, falls kein Polygon festgelegt wurde.

Siehe auch „ setPolygon()“.

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

Legt die Füllregel des Polygons auf „ rule “ fest. Die Standard-Füllregel lautet „ Qt::OddEvenFill “.

Siehe auch „ fillRule()“, „ QPainterPath::fillRule()“ und „ QPainter::drawPolygon()“.

void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon)

Legt das Polygon des Elements auf das angegebene polygon fest.

Siehe auch polygon().

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

Implementiert: ` QGraphicsItem::shape()` const.

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

Implementiert: ` 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.