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 } |
| 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 |
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 ,和 圖形視圖框架 .
此枚舉描述如何 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 . parent 被傳遞給 QGraphicsItem 的構造函數。
另請參閱 QGraphicsScene::addItem ().
構造 QGraphicsPixmapItem ,使用 pixmap 作為默認像素圖。 parent 被傳遞給 QGraphicsItem 的構造函數。
另請參閱 QGraphicsScene::addItem ().
銷毀 QGraphicsPixmapItem .
[虛擬]
QRectF
QGraphicsPixmapItem::
boundingRect
() const
重實現自 QGraphicsItem::boundingRect ().
[虛擬]
bool
QGraphicsPixmapItem::
contains
(const
QPointF
&
point
) const
重實現自 QGraphicsItem::contains ().
[虛擬]
bool
QGraphicsPixmapItem::
isObscuredBy
(const
QGraphicsItem
*
item
) const
重實現自 QGraphicsItem::isObscuredBy ().
返迴像素圖項的 offset ,以本地坐標定義像素圖的左上角點。
另請參閱 setOffset ().
[虛擬]
QPainterPath
QGraphicsPixmapItem::
opaqueArea
() const
重實現自 QGraphicsItem::opaqueArea ().
[虛擬]
void
QGraphicsPixmapItem::
paint
(
QPainter
*
painter
, const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
重實現自 QGraphicsItem::paint ().
返迴項的像素圖,或無效 QPixmap 若沒有設置像素圖。
另請參閱 setPixmap ().
將像素圖項的偏移設為 offset . QGraphicsPixmapItem will draw its pixmap using offset for its top-left corner.
另請參閱 offset ().
此方便函數相當於調用 setOffset ( QPointF ( x , y )).
該函數在 Qt 4.3 引入。
將項的像素圖設為 pixmap .
另請參閱 pixmap ().
將項的形狀模式設為 mode 。形狀模式描述如何 QGraphicsPixmapItem 計算其形狀。默認模式為 MaskShape .
另請參閱 shapeMode () 和 ShapeMode .
將像素圖項的變換模式設為 mode ,並觸發項的更新。默認模式為 Qt::FastTransformation ,提供沒有平滑的快速變換。
Qt::SmoothTransformation 啓用 QPainter::SmoothPixmapTransform 在描繪器,且品質從屬平颱和視口。結果通常不如直接調用 QPixmap::scale() 好。
另請參閱 transformationMode ().
[虛擬]
QPainterPath
QGraphicsPixmapItem::
shape
() const
重實現自 QGraphicsItem::shape ().
返迴項的形狀模式。形狀模式描述如何 QGraphicsPixmapItem 計算其形狀。默認模式為 MaskShape .
另請參閱 setShapeMode () 和 ShapeMode .
返迴像素圖的變換模式。默認模式為 Qt::FastTransformation ,提供沒有平滑的快速變換。
另請參閱 setTransformationMode ().
[虛擬]
int
QGraphicsPixmapItem::
type
() const
重實現自 QGraphicsItem::type ().