内容表

上一话题

QGraphicsPathItem

下一话题

QGraphicsPolygonItem

QGraphicsPixmapItem

QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene . 更多

Inheritance diagram of PySide2.QtWidgets.QGraphicsPixmapItem

概要

函数

详细描述

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() ,和 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, FastTransformation is used, which provides fast, non-smooth scaling. SmoothTransformation enables 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 QGraphicsPixmapItem ( [ parent=None ] )

QGraphicsPixmapItem(pixmap[, parent=None])

param parent

QGraphicsItem

param pixmap

QPixmap

构造 QGraphicsPixmapItem . parent 会被传递给 QGraphicsItem ‘s constructor.

另请参阅

addItem()

构造 QGraphicsPixmapItem ,使用 pixmap 作为默认像素图。 parent 会被传递给 QGraphicsItem ‘s constructor.

另请参阅

addItem()

PySide2.QtWidgets.QGraphicsPixmapItem. ShapeMode

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

The default value is .

常量

描述

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 ( )
返回类型

QPointF

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

另请参阅

setOffset()

PySide2.QtWidgets.QGraphicsPixmapItem. pixmap ( )
返回类型

QPixmap

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

另请参阅

setPixmap()

PySide2.QtWidgets.QGraphicsPixmapItem. setOffset ( offset )
参数

offset QPointF

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

另请参阅

offset()

PySide2.QtWidgets.QGraphicsPixmapItem. setOffset ( x , y )
参数
  • x qreal

  • y qreal

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

PySide2.QtWidgets.QGraphicsPixmapItem. setPixmap ( pixmap )
参数

pixmap QPixmap

Sets the item’s pixmap to pixmap .

另请参阅

pixmap()

PySide2.QtWidgets.QGraphicsPixmapItem. setShapeMode ( mode )
参数

mode ShapeMode

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

另请参阅

shapeMode() ShapeMode

PySide2.QtWidgets.QGraphicsPixmapItem. setTransformationMode ( mode )
参数

mode TransformationMode

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

SmoothTransformation enables 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.

PySide2.QtWidgets.QGraphicsPixmapItem. shapeMode ( )
返回类型

ShapeMode

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

另请参阅

setShapeMode() ShapeMode

PySide2.QtWidgets.QGraphicsPixmapItem. transformationMode ( )
返回类型

TransformationMode

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