QGraphicsPixmapItem 类

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

头: #include <QGraphicsPixmapItem>
qmake: QT += widgets
Since: 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

额外继承成员

详细描述

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

要设置项的像素图,传递 QPixmap to QGraphicsPixmapItem 's constructor, or call the setPixmap () 函数。 pixmap () 函数返回当前像素图。

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

像素图的绘制在项的 (0, 0) 坐标处,作为返回通过 offset ()。可以改变绘制偏移通过调用 setOffset ().

可以设置像素图的变换模式通过调用 setTransformationMode ()。默认情况下, Qt::FastTransformation 的使用,提供快速、非平滑的比例缩放。 Qt::SmoothTransformation 启用 QPainter::SmoothPixmapTransform 在描绘器,且品质从属平台和视口。结果通常不如直接调用 QPixmap::scale() 好。调用 transformationMode () 以获取项的当前变换模式。

另请参阅 QGraphicsPathItem , QGraphicsRectItem , QGraphicsEllipseItem , QGraphicsTextItem , QGraphicsPolygonItem , QGraphicsLineItem ,和 图形视图框架 .

成员类型文档编制

enum QGraphicsPixmapItem:: ShapeMode

此枚举描述如何 QGraphicsPixmapItem 计算其形状和不透明区域。

默认值为 MaskShape。

常量 描述
QGraphicsPixmapItem::MaskShape 0 形状的确定是通过调用 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)

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

另请参阅 QGraphicsScene::addItem ().

QGraphicsPixmapItem:: QGraphicsPixmapItem (const QPixmap & pixmap , QGraphicsItem * parent = Q_NULLPTR)

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

另请参阅 QGraphicsScene::addItem ().

QGraphicsPixmapItem:: ~QGraphicsPixmapItem ()

销毁 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

返回像素图项的 offset ,以本地坐标定义像素图的左上角点。

另请参阅 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

返回项的像素图,或无效 QPixmap 若没有设置像素图。

另请参阅 setPixmap ().

void QGraphicsPixmapItem:: setOffset (const QPointF & offset )

将像素图项的偏移设为 offset . QGraphicsPixmapItem will draw its pixmap using offset for its top-left corner.

另请参阅 offset ().

void QGraphicsPixmapItem:: setOffset ( qreal x , qreal y )

此方便函数相当于调用 setOffset ( QPointF ( x , y )).

该函数在 Qt 4.3 引入。

void QGraphicsPixmapItem:: setPixmap (const QPixmap & pixmap )

将项的像素图设为 pixmap .

另请参阅 pixmap ().

void QGraphicsPixmapItem:: setShapeMode ( ShapeMode mode )

将项的形状模式设为 mode 。形状模式描述如何 QGraphicsPixmapItem 计算其形状。默认模式为 MaskShape .

另请参阅 shapeMode () 和 ShapeMode .

void QGraphicsPixmapItem:: setTransformationMode ( Qt::TransformationMode mode )

将像素图项的变换模式设为 mode ,并触发项的更新。默认模式为 Qt::FastTransformation ,提供没有平滑的快速变换。

Qt::SmoothTransformation 启用 QPainter::SmoothPixmapTransform 在描绘器,且品质从属平台和视口。结果通常不如直接调用 QPixmap::scale() 好。

另请参阅 transformationMode ().

[virtual] QPainterPath QGraphicsPixmapItem:: shape () const

重实现自 QGraphicsItem::shape ().

ShapeMode QGraphicsPixmapItem:: shapeMode () const

返回项的形状模式。形状模式描述如何 QGraphicsPixmapItem 计算其形状。默认模式为 MaskShape .

另请参阅 setShapeMode () 和 ShapeMode .

Qt::TransformationMode QGraphicsPixmapItem:: transformationMode () const

返回像素图的变换模式。默认模式为 Qt::FastTransformation ,提供没有平滑的快速变换。

另请参阅 setTransformationMode ().

[virtual] int QGraphicsPixmapItem:: type () const

重实现自 QGraphicsItem::type ().