QGraphicsPixmapItem Class
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene. 更多...
头文件: | #include <QGraphicsPixmapItem> |
qmake: | QT += widgets |
开始支持版本: | Qt 4.2 |
基类: | QGraphicsItem |
公有类型
enum | ShapeMode { MaskShape, BoundingRectShape, HeuristicMaskShape } |
公有函数
QGraphicsPixmapItem(QGraphicsItem *parent = Q_NULLPTR) | |
QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = Q_NULLPTR) | |
~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 |
- 176 个公有函数继承自 QGraphicsItem
其他继承的成员
- 2 个静态公有成员继承自 QGraphicsItem
- 24 个受保护的函数继承自 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() 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.
参见 QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, and Graphics View Framework.
成员类型
enum QGraphicsPixmapItem::ShapeMode
This enum describes how QGraphicsPixmapItem calculates its shape and opaque area.
The default value is MaskShape.
Constant | Value | Description |
---|---|---|
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::QGraphicsPixmapItem(QGraphicsItem *parent = Q_NULLPTR)
Constructs a QGraphicsPixmapItem. parent is passed to QGraphicsItem's constructor.
参见 QGraphicsScene::addItem().
QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = Q_NULLPTR)
Constructs a QGraphicsPixmapItem, using pixmap as the default pixmap. parent is passed to QGraphicsItem's constructor.
参见 QGraphicsScene::addItem().
QGraphicsPixmapItem::~QGraphicsPixmapItem()
Destroys the QGraphicsPixmapItem.
[virtual]
QRectF QGraphicsPixmapItem::boundingRect() const
重新实现 QGraphicsItem::boundingRect().
[virtual]
bool QGraphicsPixmapItem::contains(const QPointF &point) const
重新实现 QGraphicsItem::contains().
[virtual]
bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const
重新实现 QGraphicsItem::isObscuredBy().
QPointF QGraphicsPixmapItem::offset() const
Returns the pixmap item's offset, which defines the point of the top-left corner of the pixmap, in local coordinates.
参见 setOffset().
[virtual]
QPainterPath QGraphicsPixmapItem::opaqueArea() const
重新实现 QGraphicsItem::opaqueArea().
[virtual]
void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
重新实现 QGraphicsItem::paint().
QPixmap QGraphicsPixmapItem::pixmap() const
Returns the item's pixmap, or an invalid QPixmap if no pixmap has been set.
参见 setPixmap().
void QGraphicsPixmapItem::setOffset(const QPointF &offset)
Sets the pixmap item's offset to offset. QGraphicsPixmapItem will draw its pixmap using offset for its top-left corner.
参见 offset().
void QGraphicsPixmapItem::setOffset(qreal x, qreal y)
This convenience function is equivalent to calling setOffset(QPointF(x, y)).
This function was introduced in Qt 4.3.
void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap)
Sets the item's pixmap to pixmap.
参见 pixmap().
void QGraphicsPixmapItem::setShapeMode(ShapeMode mode)
Sets the item's shape mode to mode. The shape mode describes how QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.
void QGraphicsPixmapItem::setTransformationMode(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.
参见 transformationMode().
[virtual]
QPainterPath QGraphicsPixmapItem::shape() const
重新实现 QGraphicsItem::shape().
ShapeMode QGraphicsPixmapItem::shapeMode() const
Returns the item's shape mode. The shape mode describes how QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.
参见 setShapeMode() and ShapeMode.
Qt::TransformationMode QGraphicsPixmapItem::transformationMode() const
Returns the transformation mode of the pixmap. The default mode is Qt::FastTransformation, which provides quick transformation with no smoothing.
参见 setTransformationMode().
[virtual]
int QGraphicsPixmapItem::type() const
重新实现 QGraphicsItem::type().