QGraphicsPathItem Class

Die Klasse QGraphicsPathItem stellt ein Pfadelement zur Verfügung, das Sie einem QGraphicsScene hinzufügen können. Mehr...

Kopfzeile: #include <QGraphicsPathItem>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
Vererbt: QAbstractGraphicsShapeItem

Öffentliche Typen

enum anonymous { Type }

Öffentliche Funktionen

QGraphicsPathItem(QGraphicsItem *parent = nullptr)
QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = nullptr)
virtual ~QGraphicsPathItem()
QPainterPath path() const
void setPath(const QPainterPath &path)

Reimplementierte ö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

Detaillierte Beschreibung

Um den Pfad des Elements zu setzen, übergeben Sie eine QPainterPath an den Konstruktor von QGraphicsPathItem oder rufen Sie die Funktion setPath() auf. Die Funktion path() gibt den aktuellen Pfad zurück.

QGraphicsPathItem verwendet den Pfad, um eine sinnvolle Implementierung von boundingRect(), shape() und contains() zu ermöglichen. Die Funktion paint() zeichnet den Pfad unter Verwendung des dem Element zugeordneten Stifts und Pinsels, die Sie durch Aufruf der Funktionen setPen() und setBrush() einstellen können.

Siehe auch QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, und Graphics View Framework.

Dokumentation der Mitgliedstypen

enum QGraphicsPathItem::anonymous

Der Wert, der von der virtuellen Funktion type() zurückgegeben wird.

KonstanteWertBeschreibung
QGraphicsPathItem::Type2Ein Grafikpfad-Element

Dokumentation der Mitgliedsfunktionen

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

Konstruiert einen QGraphicsPath. parent wird an den Konstruktor von QAbstractGraphicsShapeItem übergeben.

Siehe auch QGraphicsScene::addItem().

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

Konstruiert ein QGraphicsPath-Element mit path als Standardpfad. parent wird an den Konstruktor von QAbstractGraphicsShapeItem übergeben.

Siehe auch QGraphicsScene::addItem().

[virtual noexcept] QGraphicsPathItem::~QGraphicsPathItem()

Zerstört die QGraphicsPathItem.

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

Reimplements: QGraphicsItem::boundingRect() const.

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

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

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

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

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

Reimplements: QAbstractGraphicsShapeItem::opaqueArea() const.

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

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

QPainterPath QGraphicsPathItem::path() const

Gibt den Pfad des Elements als QPainterPath zurück. Wurde kein Element festgelegt, wird ein leeres QPainterPath zurückgegeben.

Siehe auch setPath().

void QGraphicsPathItem::setPath(const QPainterPath &path)

Setzt den Pfad des Objekts auf den angegebenen path.

Siehe auch path().

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

Reimplements: QGraphicsItem::shape() const.

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

Reimplements: QGraphicsItem::type() const.

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