QGraphicsPixmapItem Class
Die Klasse QGraphicsPixmapItem stellt ein Pixmap-Element bereit, das Sie einem QGraphicsScene hinzufügen können. Mehr...
Kopfzeile: | #include <QGraphicsPixmapItem> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
Vererbungen: | 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 |
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) override |
virtual QPainterPath | shape() const override |
virtual int | type() const override |
Detaillierte Beschreibung
Um die Pixmap des Elements zu setzen, ü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 verwendet die optionale Alphamaske von pixmap, um eine sinnvolle Implementierung von boundingRect(), shape() und contains() zu ermöglichen.
Die Pixmap wird an der (0, 0)-Koordinate des Elements gezeichnet, wie von offset() zurückgegeben. Sie können den Zeichenoffset durch den Aufruf von setOffset() ändern.
Sie können den Transformationsmodus der Pixmap durch den Aufruf von setTransformationMode() einstellen. Standardmäßig wird Qt::FastTransformation verwendet, was eine schnelle, nicht-glatte Skalierung ermöglicht. Qt::SmoothTransformation aktiviert QPainter::SmoothPixmapTransform für den Painter, und die Qualität hängt von der Plattform und dem Ansichtsfenster ab. Das Ergebnis ist normalerweise nicht so gut wie der direkte Aufruf von QPixmap::scale(). Rufen Sie transformationMode() auf, um den aktuellen Transformationsmodus für das Element zu erhalten.
Siehe auch QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, und Graphics View Framework.
Dokumentation der 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() bestimmt. Diese Form umfasst nur die undurchsichtigen Pixel der Pixmap. Da die Form jedoch komplexer ist, kann sie langsamer sein als die anderen Modi und benötigt mehr Speicher. |
QGraphicsPixmapItem::BoundingRectShape | 1 | Die Form wird durch Nachzeichnen des Umrisses der Pixmap bestimmt. Dies ist der schnellste Formmodus, berücksichtigt aber keine transparenten Bereiche auf der Pixmap. |
QGraphicsPixmapItem::HeuristicMaskShape | 2 | Die Form wird durch den Aufruf von QPixmap::createHeuristicMask() bestimmt. Die Leistung und der Speicherverbrauch sind ähnlich wie bei MaskShape. |
enum QGraphicsPixmapItem::anonymous
Der Wert, der von der virtuellen Funktion type() zurückgegeben wird.
Konstante | Wert | Beschreibung |
---|---|---|
QGraphicsPixmapItem::Type | 7 | Ein Grafik-Pixmap-Element |
Dokumentation der Mitgliedsfunktionen
[explicit]
QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent = nullptr)
Konstruiert ein QGraphicsPixmapItem. parent wird an den Konstruktor von QGraphicsItem übergeben.
Siehe auch QGraphicsScene::addItem().
[explicit]
QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = nullptr)
Konstruiert ein QGraphicsPixmapItem, wobei pixmap als Standard-Pixmap verwendet wird. 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
Reimplements: QGraphicsItem::boundingRect() const.
[override virtual]
bool QGraphicsPixmapItem::contains(const QPointF &point) const
Reimplements: QGraphicsItem::contains(const QPointF &point) const.
[override virtual]
bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const
Reimplements: QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const.
QPointF QGraphicsPixmapItem::offset() const
Liefert den Offset des Pixmap-Elements, der den Punkt der linken oberen Ecke der Pixmap definiert, in lokalen Koordinaten.
Siehe auch setOffset().
[override virtual]
QPainterPath QGraphicsPixmapItem::opaqueArea() const
Reimplements: QGraphicsItem::opaqueArea() const.
[override virtual]
void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Reimplements: QGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget).
QPixmap QGraphicsPixmapItem::pixmap() const
Gibt die Pixmap des Objekts zurück oder eine ungültige QPixmap, wenn keine Pixmap festgelegt wurde.
Siehe auch setPixmap().
void QGraphicsPixmapItem::setOffset(const QPointF &offset)
Setzt den Offset des Pixmap-Elements auf offset. QGraphicsPixmapItem zeichnet seine Pixmap unter Verwendung von offset für die obere linke Ecke.
Siehe auch offset().
void QGraphicsPixmapItem::setOffset(qreal x, qreal y)
Diese Komfortfunktion ist gleichbedeutend mit dem Aufruf von setOffset(QPointF(x, y)).
void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap)
Setzt die Pixmap des Objekts 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 eine Aktualisierung des Elements ein. Der Standardmodus ist Qt::FastTransformation, der eine schnelle Transformation ohne Glättung ermöglicht.
Qt::SmoothTransformation aktiviert QPainter::SmoothPixmapTransform auf dem Painter, und die Qualität hängt von der Plattform und dem Ansichtsfenster ab. Das Ergebnis ist normalerweise nicht so gut wie der direkte Aufruf von QPixmap::scale().
Siehe auch transformationMode().
[override virtual]
QPainterPath QGraphicsPixmapItem::shape() const
Reimplements: QGraphicsItem::shape() const.
QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode() const
Gibt den Formmodus des Objekts 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
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.