QGraphicsPixmapItem#

The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene . More

Inheritance diagram of PySide6.QtWidgets.QGraphicsPixmapItem

Synopsis#

Functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

To set the item’s pixmap, pass a QPixmap to QGraphicsPixmapItem ‘s constructor, or call the setPixmap() function. The pixmap() function returns the current pixmap.

QGraphicsPixmapItem uses pixmap’s optional alpha mask to provide a reasonable implementation of boundingRect() , shape() , and contains() .

../../_images/graphicsview-pixmapitem.png

The pixmap is drawn at the item’s (0, 0) coordinate, as returned by offset() . You can change the drawing offset by calling setOffset() .

You can set the pixmap’s transformation mode by calling setTransformationMode() . By default, Qt::FastTransformation is used, which provides fast, non-smooth scaling. Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the painter, and the quality depends on the platform and viewport. The result is usually not as good as calling QPixmap::scale() directly. Call transformationMode() to get the current transformation mode for the item.

class PySide6.QtWidgets.QGraphicsPixmapItem([parent=None])#

PySide6.QtWidgets.QGraphicsPixmapItem(pixmap[, parent=None])

Parameters:

Constructs a QGraphicsPixmapItem . parent is passed to QGraphicsItem ‘s constructor.

See also

addItem()

Constructs a QGraphicsPixmapItem , using pixmap as the default pixmap. parent is passed to QGraphicsItem ‘s constructor.

See also

addItem()

PySide6.QtWidgets.QGraphicsPixmapItem.ShapeMode#

This enum describes how QGraphicsPixmapItem calculates its shape and opaque area.

The default value is MaskShape.

Constant

Description

QGraphicsPixmapItem.MaskShape

The shape is determined by calling QPixmap::mask(). This shape includes only the opaque pixels of the pixmap. Because the shape is more complex, however, it can be slower than the other modes, and uses more memory.

QGraphicsPixmapItem.BoundingRectShape

The shape is determined by tracing the outline of the pixmap. This is the fastest shape mode, but it does not take into account any transparent areas on the pixmap.

QGraphicsPixmapItem.HeuristicMaskShape

The shape is determine by calling QPixmap::createHeuristicMask(). The performance and memory consumption is similar to MaskShape.

PySide6.QtWidgets.QGraphicsPixmapItem.offset()#
Return type:

PySide6.QtCore.QPointF

Returns the pixmap item’s offset, which defines the point of the top-left corner of the pixmap, in local coordinates.

See also

setOffset()

PySide6.QtWidgets.QGraphicsPixmapItem.pixmap()#
Return type:

PySide6.QtGui.QPixmap

Returns the item’s pixmap, or an invalid QPixmap if no pixmap has been set.

See also

setPixmap()

PySide6.QtWidgets.QGraphicsPixmapItem.setOffset(offset)#
Parameters:

offsetPySide6.QtCore.QPointF

Sets the pixmap item’s offset to offset. QGraphicsPixmapItem will draw its pixmap using offset for its top-left corner.

See also

offset()

PySide6.QtWidgets.QGraphicsPixmapItem.setOffset(x, y)
Parameters:
  • x – float

  • y – float

This convenience function is equivalent to calling setOffset (QPointF(x, y)).

PySide6.QtWidgets.QGraphicsPixmapItem.setPixmap(pixmap)#
Parameters:

pixmapPySide6.QtGui.QPixmap

Sets the item’s pixmap to pixmap.

See also

pixmap()

PySide6.QtWidgets.QGraphicsPixmapItem.setShapeMode(mode)#
Parameters:

modeShapeMode

Sets the item’s shape mode to mode. The shape mode describes how QGraphicsPixmapItem calculates its shape. The default mode is MaskShape .

See also

shapeMode() ShapeMode

PySide6.QtWidgets.QGraphicsPixmapItem.setTransformationMode(mode)#
Parameters:

modeTransformationMode

Sets the pixmap item’s transformation mode to mode, and toggles an update of the item. The default mode is Qt::FastTransformation, which provides quick transformation with no smoothing.

Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the painter, and the quality depends on the platform and viewport. The result is usually not as good as calling QPixmap::scale() directly.

PySide6.QtWidgets.QGraphicsPixmapItem.shapeMode()#
Return type:

ShapeMode

Returns the item’s shape mode. The shape mode describes how QGraphicsPixmapItem calculates its shape. The default mode is MaskShape .

See also

setShapeMode() ShapeMode

PySide6.QtWidgets.QGraphicsPixmapItem.transformationMode()#
Return type:

TransformationMode

Returns the transformation mode of the pixmap. The default mode is Qt::FastTransformation, which provides quick transformation with no smoothing.