
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQGraphicsPixmapItem class provides a pixmap item that you can add to aQGraphicsScene.More...
| Header: | #include <QGraphicsPixmapItem> |
| Since: | Qt 4.2 |
| Inherits: | QGraphicsItem |
| enum | ShapeMode { MaskShape, BoundingRectShape, HeuristicMaskShape } |
| QGraphicsPixmapItem(QGraphicsItem * parent = 0) | |
| QGraphicsPixmapItem(const QPixmap & pixmap, QGraphicsItem * parent = 0) | |
| ~QGraphicsPixmapItem() | |
| QPointF | offset() const |
| QPixmap | pixmap() const |
| void | setOffset(const QPointF & offset) |
| void | setOffset(qreal x, qreal y) |
| void | setPixmap(const QPixmap & pixmap) |
| void | setShapeMode(ShapeMode mode) |
| void | setTransformationMode(Qt::TransformationMode mode) |
| ShapeMode | shapeMode() const |
| Qt::TransformationMode | transformationMode() const |
| virtual QRectF | boundingRect() const |
| virtual bool | contains(const QPointF & point) const |
| virtual bool | isObscuredBy(const QGraphicsItem * item) const |
| virtual QPainterPath | opaqueArea() const |
| virtual void | paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) |
| virtual QPainterPath | shape() const |
| virtual int | type() const |
TheQGraphicsPixmapItem class provides a pixmap item that you can add to aQGraphicsScene.
To set the item's pixmap, pass aQPixmap toQGraphicsPixmapItem's constructor, or call thesetPixmap() function. Thepixmap() function returns the current pixmap.
QGraphicsPixmapItem uses pixmap's optional alpha mask to provide a reasonable implementation ofboundingRect(),shape(), andcontains().

The pixmap is drawn at the item's (0, 0) coordinate, as returned byoffset(). You can change the drawing offset by callingsetOffset().
You can set the pixmap's transformation mode by callingsetTransformationMode(). By default,Qt::FastTransformation is used, which provides fast, non-smooth scaling.Qt::SmoothTransformation enablesQPainter::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. CalltransformationMode() to get the current transformation mode for the item.
See alsoQGraphicsPathItem,QGraphicsRectItem,QGraphicsEllipseItem,QGraphicsTextItem,QGraphicsPolygonItem,QGraphicsLineItem, andGraphics View Framework.
This enum describes howQGraphicsPixmapItem calculates its shape and opaque area.
The default value is MaskShape.
| Constant | Value | Description |
|---|---|---|
QGraphicsPixmapItem::MaskShape | 0 | The shape is determined by callingQPixmap::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 callingQPixmap::createHeuristicMask(). The performance and memory consumption is similar to MaskShape. |
Constructs aQGraphicsPixmapItem.parent is passed toQGraphicsItem's constructor.
See alsoQGraphicsScene::addItem().
Constructs aQGraphicsPixmapItem, usingpixmap as the default pixmap.parent is passed toQGraphicsItem's constructor.
See alsoQGraphicsScene::addItem().
Destroys theQGraphicsPixmapItem.
[virtual]QRectF QGraphicsPixmapItem::boundingRect() constReimplemented fromQGraphicsItem::boundingRect().
[virtual]bool QGraphicsPixmapItem::contains(constQPointF & point) constReimplemented fromQGraphicsItem::contains().
[virtual]bool QGraphicsPixmapItem::isObscuredBy(constQGraphicsItem * item) constReimplemented fromQGraphicsItem::isObscuredBy().
Returns the pixmap item'soffset, which defines the point of the top-left corner of the pixmap, in local coordinates.
See alsosetOffset().
[virtual]QPainterPath QGraphicsPixmapItem::opaqueArea() constReimplemented fromQGraphicsItem::opaqueArea().
[virtual]void QGraphicsPixmapItem::paint(QPainter * painter, constQStyleOptionGraphicsItem * option,QWidget * widget)Reimplemented fromQGraphicsItem::paint().
Returns the item's pixmap, or an invalidQPixmap if no pixmap has been set.
See alsosetPixmap().
Sets the pixmap item's offset tooffset.QGraphicsPixmapItem will draw its pixmap usingoffset for its top-left corner.
See alsooffset().
This convenience function is equivalent to callingsetOffset(QPointF(x,y)).
This function was introduced in Qt 4.3.
Sets the item's pixmap topixmap.
See alsopixmap().
Sets the item's shape mode tomode. The shape mode describes howQGraphicsPixmapItem calculates its shape. The default mode isMaskShape.
See alsoshapeMode() andShapeMode.
Sets the pixmap item's transformation mode tomode, and toggles an update of the item. The default mode isQt::FastTransformation, which provides quick transformation with no smoothing.
Qt::SmoothTransformation enablesQPainter::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 alsotransformationMode().
[virtual]QPainterPath QGraphicsPixmapItem::shape() constReimplemented fromQGraphicsItem::shape().
Returns the item's shape mode. The shape mode describes howQGraphicsPixmapItem calculates its shape. The default mode isMaskShape.
See alsosetShapeMode() andShapeMode.
Returns the transformation mode of the pixmap. The default mode isQt::FastTransformation, which provides quick transformation with no smoothing.
See alsosetTransformationMode().
[virtual]int QGraphicsPixmapItem::type() constReimplemented fromQGraphicsItem::type().
© 2016 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 theGNU 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.