QGraphicsPixmapItem露
The
QGraphicsPixmapItemclass provides a pixmap item that you can add to aQGraphicsScene. More鈥�

Synopsis露
Functions露
def
offset()def
pixmap()def
setOffset(offset)def
setOffset(x, y)def
setPixmap(pixmap)def
setShapeMode(mode)def
setTransformationMode(mode)def
shapeMode()def
transformationMode()
Detailed Description露
To set the item鈥檚 pixmap, pass a
QPixmaptoQGraphicsPixmapItem鈥榮 constructor, or call thesetPixmap()function. Thepixmap()function returns the current pixmap.
QGraphicsPixmapItemuses pixmap鈥檚 optional alpha mask to provide a reasonable implementation ofboundingRect(),shape(), andcontains().![]()
The pixmap is drawn at the item鈥檚 (0, 0) coordinate, as returned by
offset(). You can change the drawing offset by callingsetOffset().You can set the pixmap鈥檚 transformation mode by calling
setTransformationMode(). By default,FastTransformationis used, which provides fast, non-smooth scaling.SmoothTransformationenablesSmoothPixmapTransformon the painter, and the quality depends on the platform and viewport. The result is usually not as good as calling QPixmap::scale() directly. CalltransformationMode()to get the current transformation mode for the item.
- class PySide2.QtWidgets.QGraphicsPixmapItem([parent=None])露
PySide2.QtWidgets.QGraphicsPixmapItem(pixmap[, parent=None])
- param parent:
- param pixmap:
Constructs a
QGraphicsPixmapItem.parentis passed toQGraphicsItem鈥榮 constructor.See also
Constructs a
QGraphicsPixmapItem, usingpixmapas the default pixmap.parentis passed toQGraphicsItem鈥榮 constructor.See also
- PySide2.QtWidgets.QGraphicsPixmapItem.ShapeMode露
This enum describes how
QGraphicsPixmapItemcalculates its shape and opaque area.The default value is .
Constant
Description
QGraphicsPixmapItem.MaskShape
The shape is determined by calling
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
createHeuristicMask(). The performance and memory consumption is similar to .
- PySide2.QtWidgets.QGraphicsPixmapItem.offset()露
- Return type:
Returns the pixmap item鈥檚 offset , which defines the point of the top-left corner of the pixmap, in local coordinates.
See also
- PySide2.QtWidgets.QGraphicsPixmapItem.pixmap()露
- Return type:
Returns the item鈥檚 pixmap, or an invalid
QPixmapif no pixmap has been set.See also
- PySide2.QtWidgets.QGraphicsPixmapItem.setOffset(offset)露
- Parameters:
offset 鈥�
PySide2.QtCore.QPointF
Sets the pixmap item鈥檚 offset to
offset.QGraphicsPixmapItemwill draw its pixmap usingoffsetfor its top-left corner.See also
- PySide2.QtWidgets.QGraphicsPixmapItem.setOffset(x, y)
- Parameters:
x 鈥� float
y 鈥� float
This convenience function is equivalent to calling
setOffset(QPointF(x,y)).
- PySide2.QtWidgets.QGraphicsPixmapItem.setPixmap(pixmap)露
- Parameters:
pixmap 鈥�
PySide2.QtGui.QPixmap
Sets the item鈥檚 pixmap to
pixmap.See also
- PySide2.QtWidgets.QGraphicsPixmapItem.setShapeMode(mode)露
- Parameters:
mode 鈥�
ShapeMode
Sets the item鈥檚 shape mode to
mode. The shape mode describes howQGraphicsPixmapItemcalculates its shape. The default mode isMaskShape.See also
shapeMode()ShapeMode
- PySide2.QtWidgets.QGraphicsPixmapItem.setTransformationMode(mode)露
- Parameters:
mode 鈥�
TransformationMode
Sets the pixmap item鈥檚 transformation mode to
mode, and toggles an update of the item. The default mode isFastTransformation, which provides quick transformation with no smoothing.SmoothTransformationenablesSmoothPixmapTransformon the painter, and the quality depends on the platform and viewport. The result is usually not as good as calling QPixmap::scale() directly.See also
- PySide2.QtWidgets.QGraphicsPixmapItem.shapeMode()露
- Return type:
Returns the item鈥檚 shape mode. The shape mode describes how
QGraphicsPixmapItemcalculates its shape. The default mode isMaskShape.See also
setShapeMode()ShapeMode
- PySide2.QtWidgets.QGraphicsPixmapItem.transformationMode()露
- Return type:
Returns the transformation mode of the pixmap. The default mode is
FastTransformation, which provides quick transformation with no smoothing.See also
漏 2022 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.