QGraphicsPixmapItem Class Reference

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

  1. #include <QGraphicsPixmapItem>

Inherits: QGraphicsItem.

This class was introduced in Qt 4.2.

Detailed Description

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() 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().

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.

See also QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, and Graphics View Framework.

Public Types

Toggle detailsenum QGraphicsPixmapItem::

ShapeModeShapeMode { MaskShape , BoundingRectShape , HeuristicMaskShape 2 ...} { MaskShape , BoundingRectShape , HeuristicMaskShape 2 }

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

The default value is MaskShape.

ConstantValueDescription
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.

Look up this member in the source code.

    Public Functions

    Toggle details QGraphicsPixmapItem

    QGraphicsPixmapItemQGraphicsPixmapItem ( QGraphicsItem *parent=0 ) ( QGraphicsItem *parent=0 )

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

    See also QGraphicsScene::addItem().

    Look up this member in the source code.

    Toggle details QGraphicsPixmapItem

    QGraphicsPixmapItemQGraphicsPixmapItem ( const QPixmap &pixmap , QGraphicsItem *parent=0 ...) ( const QPixmap &pixmap , QGraphicsItem *parent=0 )

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

    See also QGraphicsScene::addItem().

    Look up this member in the source code.

    Toggle details QGraphicsPixmapItem

    ~QGraphicsPixmapItem~QGraphicsPixmapItem () ()

    Destroys the QGraphicsPixmapItem.

    Look up this member in the source code.

    Toggle details QRectF QGraphicsPixmapItem

    boundingRectboundingRect () ()const [virtual]

    Reimplemented from QGraphicsItem::boundingRect().

    Look up this member in the source code.

    Toggle details bool QGraphicsPixmapItem

    containscontains ( const QPointF &point ) ( const QPointF &point )const [virtual]

    Reimplemented from QGraphicsItem::contains().

    Look up this member in the source code.

    Toggle details bool QGraphicsPixmapItem

    isObscuredByisObscuredBy ( const QGraphicsItem *item ) ( const QGraphicsItem *item )const [virtual]

    Reimplemented from QGraphicsItem::isObscuredBy().

    Look up this member in the source code.

    Toggle details QPointF QGraphicsPixmapItem

    offsetoffset () ()const

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

    See also setOffset().

    Look up this member in the source code.

    Toggle details QPainterPath QGraphicsPixmapItem

    opaqueAreaopaqueArea () ()const [virtual]

    Reimplemented from QGraphicsItem::opaqueArea().

    Look up this member in the source code.

    Toggle details void QGraphicsPixmapItem

    paintpaint ( QPainter *painter , const QStyleOptionGraphicsItem *option , QWidget *widget ...) ( QPainter *painter , const QStyleOptionGraphicsItem *option , QWidget *widget ) [virtual]

    Reimplemented from QGraphicsItem::paint().

    Look up this member in the source code.

    Toggle details QPixmap QGraphicsPixmapItem

    pixmappixmap () ()const

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

    See also setPixmap().

    Look up this member in the source code.

    Toggle details void QGraphicsPixmapItem

    setOffsetsetOffset ( const QPointF &offset ) ( const QPointF &offset )

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

    See also offset().

    Look up this member in the source code.

    Toggle details void QGraphicsPixmapItem

    setOffsetsetOffset ( qreal x , qreal y ) ( qreal x , qreal y )

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

    Look up this member in the source code.

    Toggle details void QGraphicsPixmapItem

    setPixmapsetPixmap ( const QPixmap &pixmap ) ( const QPixmap &pixmap )

    Sets the item's pixmap to pixmap.

    See also pixmap().

    Look up this member in the source code.

    Toggle details void QGraphicsPixmapItem

    setShapeModesetShapeMode ( ShapeMode mode ) ( ShapeMode mode )

    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() and ShapeMode.

    Look up this member in the source code.

    Toggle details void QGraphicsPixmapItem

    setTransformationModesetTransformationMode ( Qt::TransformationMode mode ...) ( Qt::TransformationMode mode )

    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.

    See also transformationMode().

    Look up this member in the source code.

    Toggle details QPainterPath QGraphicsPixmapItem

    shapeshape () ()const [virtual]

    Reimplemented from QGraphicsItem::shape().

    Look up this member in the source code.

    Toggle details ShapeMode QGraphicsPixmapItem

    shapeModeshapeMode () ()const

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

    See also setShapeMode() and ShapeMode.

    Look up this member in the source code.

    Toggle details Qt::TransformationMode QGraphicsPixmapItem

    transformationModetransformationMode () ()const

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

    See also setTransformationMode().

    Look up this member in the source code.

    Toggle details int QGraphicsPixmapItem

    typetype () ()const [virtual]

    Reimplemented from QGraphicsItem::type().

    Look up this member in the source code.

      Notes provided by the Qt Community

      No notes