QGraphicsPathItem Class
La classe `QGraphicsPathItem` fournit un élément de tracé que vous pouvez ajouter à une ` QGraphicsScene`. En savoir plus...
| En-tête : | #include <QGraphicsPathItem> |
| CMake : | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake : | QT += widgets |
| Hérite de : | QAbstractGraphicsShapeItem |
Types publics
| enum { Type } |
Fonctions publiques
| QGraphicsPathItem(QGraphicsItem *parent = nullptr) | |
| QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = nullptr) | |
| virtual | ~QGraphicsPathItem() |
| QPainterPath | path() const |
| void | setPath(const QPainterPath &path) |
Fonctions publiques réimplémentées
| 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 |
Description détaillée
Pour définir le chemin de l'élément, transmettez un objet ` QPainterPath ` au constructeur de `QGraphicsPathItem`, ou appelez la fonction ` setPath()`. La fonction ` path()` renvoie le chemin actuel.

QGraphicsPathItem utilise le tracé pour fournir une implémentation raisonnable des fonctions boundingRect(), shape() et contains(). La fonction paint() dessine le tracé à l’aide du stylo et du pinceau associés à l’élément, que vous pouvez définir en appelant les fonctions setPen() et setBrush().
Voir également QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem et Graphics View Framework.
Documentation sur les types de membres
[anonymous] enum
Valeur renvoyée par la fonction virtuelle ` type()`.
| Constante | Valeur | Description |
|---|---|---|
QGraphicsPathItem::Type | 2 | Un élément de chemin graphique |
Documentation des fonctions membres
[explicit] QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent = nullptr)
Crée un objet `QGraphicsPath`. L'objet ` parent ` est transmis au constructeur de ` QAbstractGraphicsShapeItem`.
Voir aussi QGraphicsScene::addItem().
[explicit] QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = nullptr)
Crée un élément QGraphicsPath en utilisant ` path ` comme chemin par défaut. ` parent ` est transmis au constructeur de ` QAbstractGraphicsShapeItem`.
Voir également QGraphicsScene::addItem().
[virtual noexcept] QGraphicsPathItem::~QGraphicsPathItem()
Supprime l'QGraphicsPathItem.
[override virtual] QRectF QGraphicsPathItem::boundingRect() const
Réimplémente : QGraphicsItem::boundingRect() const.
[override virtual] bool QGraphicsPathItem::contains(const QPointF &point) const
Réimplémente : QGraphicsItem::contains(const QPointF &point) const.
[override virtual] bool QGraphicsPathItem::isObscuredBy(const QGraphicsItem *item) const
Réimplémente : QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const.
[override virtual] QPainterPath QGraphicsPathItem::opaqueArea() const
Réimplémente : QAbstractGraphicsShapeItem::opaqueArea() const.
[override virtual] void QGraphicsPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr)
Réimplémente : QGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget).
QPainterPath QGraphicsPathItem::path() const
Renvoie le chemin d'accès de l'élément sous la forme d'un objet ` QPainterPath`. Si aucun élément n'a été défini, un objet ` QPainterPath ` vide est renvoyé.
Voir également setPath().
void QGraphicsPathItem::setPath(const QPainterPath &path)
Définit le chemin d'accès de l'élément sur l'adresse path.
Voir également path().
[override virtual] QPainterPath QGraphicsPathItem::shape() const
Réimplémente : QGraphicsItem::shape() const.
[override virtual] int QGraphicsPathItem::type() const
Réimplémente : 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.