QGraphicsPixmapItem Class
Die Klasse „QGraphicsPixmapItem“ stellt ein Pixmap-Element bereit, das Sie zu einem „ QGraphicsScene “ hinzufügen können. Mehr...
| Header: | #include <QGraphicsPixmapItem> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| Erbt von: | QGraphicsItem |
Öffentliche Typen
Öffentliche Funktionen
| QGraphicsPixmapItem(QGraphicsItem *parent = nullptr) | |
| QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = nullptr) | |
| virtual | ~QGraphicsPixmapItem() |
| QPointF | offset() const |
| QPixmap | pixmap() const |
| void | setOffset(const QPointF &offset) |
| void | setOffset(qreal x, qreal y) |
| void | setPixmap(const QPixmap &pixmap) |
| void | setShapeMode(QGraphicsPixmapItem::ShapeMode mode) |
| void | setTransformationMode(Qt::TransformationMode mode) |
| QGraphicsPixmapItem::ShapeMode | shapeMode() const |
| Qt::TransformationMode | transformationMode() const |
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) override |
| virtual QPainterPath | shape() const override |
| virtual int | type() const override |
Ausführliche Beschreibung
Um die Pixmap des Elements festzulegen, übergeben Sie eine ` QPixmap ` an den Konstruktor von `QGraphicsPixmapItem` oder rufen Sie die Funktion ` setPixmap()` auf. Die Funktion ` pixmap()` gibt die aktuelle Pixmap zurück.
QGraphicsPixmapItem nutzt die optionale Alphamaske der Pixmap, um eine sinnvolle Implementierung der Funktionen ` boundingRect()`, ` shape()` und ` contains()` bereitzustellen.

Die Pixmap wird an der Koordinate (0, 0) des Elements gezeichnet, wie sie von ` offset()` zurückgegeben wird. Sie können den Zeichnungsversatz ändern, indem Sie ` setOffset()` aufrufen.
Sie können den Transformationsmodus der Pixmap festlegen, indem Sie „ setTransformationMode()“ aufrufen. Standardmäßig wird „ Qt::FastTransformation “ verwendet, was eine schnelle, jedoch nicht glatte Skalierung bietet. „ Qt::SmoothTransformation “ aktiviert „ QPainter::SmoothPixmapTransform “ für den Painter, wobei die Qualität von der Plattform und dem Viewport abhängt. Das Ergebnis ist in der Regel nicht so gut wie beim direkten Aufruf von „QPixmap::scale()“. Rufen Sie ` transformationMode()` auf, um den aktuellen Transformationsmodus für das Element abzurufen.
Siehe auch „ QGraphicsPathItem“ , „ QGraphicsRectItem “, „ QGraphicsEllipseItem “, „ QGraphicsTextItem “, „ QGraphicsPolygonItem “, „ QGraphicsLineItem “ und „Graphics View Framework“.
Dokumentation zu Mitgliedstypen
enum QGraphicsPixmapItem::ShapeMode
Diese Aufzählung beschreibt, wie „ QGraphicsPixmapItem “ seine Form und seinen undurchsichtigen Bereich berechnet.
Der Standardwert ist „MaskShape“.
| Konstante | Wert | Beschreibung |
|---|---|---|
QGraphicsPixmapItem::MaskShape | 0 | Die Form wird durch den Aufruf von ` QPixmap::mask()` ermittelt. Diese Form umfasst nur die undurchsichtigen Pixel der Pixmap. Da die Form jedoch komplexer ist, kann dieser Modus langsamer sein als die anderen und benötigt mehr Speicher. |
QGraphicsPixmapItem::BoundingRectShape | 1 | Die Form wird durch Nachzeichnen des Umrisses der Pixmap ermittelt. Dies ist der schnellste Formmodus, berücksichtigt jedoch keine transparenten Bereiche der Pixmap. |
QGraphicsPixmapItem::HeuristicMaskShape | 2 | Die Form wird durch den Aufruf von ` QPixmap::createHeuristicMask()` ermittelt. Die Leistung und der Speicherverbrauch entsprechen denen von `MaskShape`. |
[anonymous] enum
Der von der virtuellen Funktion ` type()` zurückgegebene Wert.
| Konstante | Wert | Beschreibung |
|---|---|---|
QGraphicsPixmapItem::Type | 7 | Ein Grafik-Pixmap-Element |
Dokumentation der Mitgliedsfunktionen
[explicit] QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent = nullptr)
Erstellt ein `QGraphicsPixmapItem`. ` parent ` wird an den Konstruktor von ` QGraphicsItem` übergeben.
Siehe auch QGraphicsScene::addItem().
[explicit] QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = nullptr)
Erstellt ein `QGraphicsPixmapItem` und verwendet dabei ` pixmap ` als Standard-Pixmap. ` parent ` wird an den Konstruktor von ` QGraphicsItem` übergeben.
Siehe auch QGraphicsScene::addItem().
[virtual noexcept] QGraphicsPixmapItem::~QGraphicsPixmapItem()
Zerstört die „ QGraphicsPixmapItem “.
[override virtual] QRectF QGraphicsPixmapItem::boundingRect() const
Implementiert: ` QGraphicsItem::boundingRect()` const.
[override virtual] bool QGraphicsPixmapItem::contains(const QPointF &point) const
Implementiert neu: ` QGraphicsItem::contains(const QPointF &point) const`.
[override virtual] bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const
Implementiert: QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const.
QPointF QGraphicsPixmapItem::offset() const
Gibt den Offset des Pixmap-Elements zurück, der die Position der oberen linken Ecke der Pixmap in lokalen Koordinaten definiert.
Siehe auch ` setOffset()`.
[override virtual] QPainterPath QGraphicsPixmapItem::opaqueArea() const
Implementiert neu: ` QGraphicsItem::opaqueArea()` const.
[override virtual] void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Implementiert: ` QGraphicsItem::paint` (`QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget`).
QPixmap QGraphicsPixmapItem::pixmap() const
Gibt die Pixmap des Elements zurück oder einen ungültigen Wert vom Typ „ QPixmap “, falls keine Pixmap festgelegt wurde.
Siehe auch setPixmap().
void QGraphicsPixmapItem::setOffset(const QPointF &offset)
Setzt den Versatz des Pixmap-Elements auf „ offset “. „ QGraphicsPixmapItem “ zeichnet die Pixmap so, dass die linke obere Ecke an der Position „ offset “ liegt.
Siehe auch offset().
void QGraphicsPixmapItem::setOffset(qreal x, qreal y)
Diese Komfortfunktion entspricht dem Aufruf von setOffset(QPointF(x, y)).
void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap)
Setzt die Pixmap des Elements auf pixmap.
Siehe auch pixmap().
void QGraphicsPixmapItem::setShapeMode(QGraphicsPixmapItem::ShapeMode mode)
Setzt den Formmodus des Elements auf „ mode “. Der Formmodus beschreibt, wie „ QGraphicsPixmapItem “ seine Form berechnet. Der Standardmodus ist „ MaskShape “.
Siehe auch ` shapeMode()` und ` ShapeMode`.
void QGraphicsPixmapItem::setTransformationMode(Qt::TransformationMode mode)
Setzt den Transformationsmodus des Pixmap-Elements auf „ mode “ und schaltet die Aktualisierung des Elements um. Der Standardmodus ist „ Qt::FastTransformation “, der eine schnelle Transformation ohne Glättung ermöglicht.
Qt::SmoothTransformation Aktiviert „ QPainter::SmoothPixmapTransform “ für den Painter; die Qualität hängt von der Plattform und dem Ansichtsfenster ab. Das Ergebnis ist in der Regel nicht so gut wie bei einem direkten Aufruf von `QPixmap::scale()`.
Siehe auch „ transformationMode()“.
[override virtual] QPainterPath QGraphicsPixmapItem::shape() const
Implementiert erneut: ` QGraphicsItem::shape()` const.
QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode() const
Gibt den Formmodus des Elements zurück. Der Formmodus beschreibt, wie QGraphicsPixmapItem seine Form berechnet. Der Standardmodus ist „ MaskShape “.
Siehe auch „ setShapeMode()“ und „ ShapeMode “.
Qt::TransformationMode QGraphicsPixmapItem::transformationMode() const
Gibt den Transformationsmodus der Pixmap zurück. Der Standardmodus ist „ Qt::FastTransformation “, der eine schnelle Transformation ohne Glättung ermöglicht.
Siehe auch ` setTransformationMode()`.
[override virtual] int QGraphicsPixmapItem::type() const
Implementiert neu: 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.