QGraphicsPixmapItem 類

The 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 }
enum anonymous { Type }

公共函數

QGraphicsPixmapItem (QGraphicsItem * parent = nullptr)
QGraphicsPixmapItem (const QPixmap & pixmap , QGraphicsItem * parent = nullptr)
virtual ~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 (QGraphicsPixmapItem::ShapeMode mode )
void setTransformationMode (Qt::TransformationMode mode )
QGraphicsPixmapItem::ShapeMode shapeMode () const
Qt::TransformationMode transformationMode () const

重實現公共函數

virtual QRectF boundingRect () const override
virtual bool contains (const QPointF & point ) const override
virtual bool isObscuredBy (const QGraphicsItem * item ) const override
virtual QPainterPath opaqueArea () const override
virtual void paint (QPainter * painter , const QStyleOptionGraphicsItem * option , QWidget * widget ) override
virtual QPainterPath shape () const override
virtual int type () const override

額外繼承成員

詳細描述

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

enum QGraphicsPixmapItem:: anonymous

值的返迴是通過虛擬 type () 函數。

常量 描述
QGraphicsPixmapItem::Type 7 圖形像素圖項

成員函數文檔編製

QGraphicsPixmapItem:: QGraphicsPixmapItem ( QGraphicsItem * parent = nullptr)

構造 QGraphicsPixmapItem . parent 被傳遞給 QGraphicsItem 的構造函數。

另請參閱 QGraphicsScene::addItem ().

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

構造 QGraphicsPixmapItem ,使用 pixmap 作為默認像素圖。 parent 被傳遞給 QGraphicsItem 的構造函數。

另請參閱 QGraphicsScene::addItem ().

[虛擬] QGraphicsPixmapItem:: ~QGraphicsPixmapItem ()

銷毀 QGraphicsPixmapItem .

[override virtual] QRectF QGraphicsPixmapItem:: boundingRect () const

重實現自 QGraphicsItem::boundingRect ().

[override virtual] bool QGraphicsPixmapItem:: contains (const QPointF & point ) const

重實現自 QGraphicsItem::contains ().

[override virtual] bool QGraphicsPixmapItem:: isObscuredBy (const QGraphicsItem * item ) const

重實現自 QGraphicsItem::isObscuredBy ().

QPointF QGraphicsPixmapItem:: offset () const

返迴像素圖項的 offset ,以本地坐標定義像素圖的左上角點。

另請參閱 setOffset ().

[override virtual] QPainterPath QGraphicsPixmapItem:: opaqueArea () const

重實現自 QGraphicsItem::opaqueArea ().

[override 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 ( QGraphicsPixmapItem::ShapeMode mode )

將項的形狀模式設為 mode 。形狀模式描述如何 QGraphicsPixmapItem 計算其形狀。默認模式為 MaskShape .

另請參閱 shapeMode () 和 ShapeMode .

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

將像素圖項的變換模式設為 mode ,並觸發項的更新。默認模式為 Qt::FastTransformation ,提供沒有平滑的快速變換。

Qt::SmoothTransformation 啓用 QPainter::SmoothPixmapTransform 在描繪器,且品質從屬平颱和視口。結果通常不如直接調用 QPixmap::scale() 好。

另請參閱 transformationMode ().

[override virtual] QPainterPath QGraphicsPixmapItem:: shape () const

重實現自 QGraphicsItem::shape ().

QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem:: shapeMode () const

返迴項的形狀模式。形狀模式描述如何 QGraphicsPixmapItem 計算其形狀。默認模式為 MaskShape .

另請參閱 setShapeMode () 和 ShapeMode .

Qt::TransformationMode QGraphicsPixmapItem:: transformationMode () const

返迴像素圖的變換模式。默認模式為 Qt::FastTransformation ,提供沒有平滑的快速變換。

另請參閱 setTransformationMode ().

[override virtual] int QGraphicsPixmapItem:: type () const

重實現自 QGraphicsItem::type ().