QGraphicsPixmapItem Class Reference

[ QtGui module]

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

继承 QGraphicsItem .

类型

方法


详细描述

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

To set the item's pixmap, pass a QPixmap to QGraphicsPixmapItem's constructor, or call the setPixmap () 函数。 pixmap () function returns the current pixmap.

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

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 (). 默认情况下, 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.


类型文档编制

QGraphicsPixmapItem.ShapeMode

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

The default value is MaskShape.

常量 描述
QGraphicsPixmapItem.MaskShape 0 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 1 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 2 The shape is determine by calling QPixmap.createHeuristicMask (). The performance and memory consumption is similar to MaskShape.

方法文档编制

QGraphicsPixmapItem.__init__ ( self , QGraphicsItem   parent  = None, QGraphicsScene   scene  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

scene argument, if not None, causes self to be owned by Qt instead of PyQt.

构造 QGraphicsPixmapItem . parent 会被传递给 QGraphicsItem 's 构造函数。

另请参阅 QGraphicsScene.addItem ().

QGraphicsPixmapItem.__init__ ( self , QPixmap   pixmap , QGraphicsItem   parent  = None, QGraphicsScene   scene  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

scene argument, if not None, causes self to be owned by Qt instead of PyQt.

构造 QGraphicsPixmapItem ,使用 pixmap 作为默认像素图。 parent 会被传递给 QGraphicsItem 的构造函数。

另请参阅 QGraphicsScene.addItem ().

QRectF QGraphicsPixmapItem.boundingRect ( self )

重实现自 QGraphicsItem.boundingRect ().

bool QGraphicsPixmapItem.contains ( self , QPointF   point )

重实现自 QGraphicsItem.contains ().

bool QGraphicsPixmapItem.isObscuredBy ( self , QGraphicsItem   item )

重实现自 QGraphicsItem.isObscuredBy ().

QPointF QGraphicsPixmapItem.offset ( self )

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

另请参阅 setOffset ().

QPainterPath QGraphicsPixmapItem.opaqueArea ( self )

重实现自 QGraphicsItem.opaqueArea ().

QGraphicsPixmapItem.paint ( self , QPainter   painter , QStyleOptionGraphicsItem   option , QWidget   widget )

重实现自 QGraphicsItem.paint ().

QPixmap QGraphicsPixmapItem.pixmap ( self )

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

另请参阅 setPixmap ().

QGraphicsPixmapItem.setOffset ( self , QPointF   offset )

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

另请参阅 offset ().

QGraphicsPixmapItem.setOffset ( self , float  ax , float  ay )

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

该函数在 Qt 4.3 引入。

QGraphicsPixmapItem.setPixmap ( self , QPixmap   pixmap )

Sets the item's pixmap to pixmap .

另请参阅 pixmap ().

QGraphicsPixmapItem.setShapeMode ( self , ShapeMode   mode )

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

另请参阅 shapeMode () 和 ShapeMode .

QGraphicsPixmapItem.setTransformationMode ( self , Qt.TransformationMode   mode )

Sets the pixmap item's transformation mode to mode ,和 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.

另请参阅 transformationMode ().

QPainterPath QGraphicsPixmapItem.shape ( self )

重实现自 QGraphicsItem.shape ().

ShapeMode QGraphicsPixmapItem.shapeMode ( self )

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

另请参阅 setShapeMode () 和 ShapeMode .

Qt.TransformationMode QGraphicsPixmapItem.transformationMode ( self )

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

另请参阅 setTransformationMode ().

int QGraphicsPixmapItem.type ( self )

重实现自 QGraphicsItem.type ().