QGraphicsPixmapItem Class
QGraphicsPixmapItem クラスは、QGraphicsScene に追加できるピクマップアイテムを提供します。詳細...
| ヘッダー: | #include <QGraphicsPixmapItem> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| 継承元: | QGraphicsItem |
パブリック型
パブリック関数
| 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 |
詳細な説明
アイテムのピクマップを設定するには、QPixmap をQGraphicsPixmapItemのコンストラクタに渡すか、setPixmap()関数を呼び出します。pixmap()関数は、現在のピクマップを返します。
QGraphicsPixmapItem は、pixmap のオプションのアルファマスクを使用して、boundingRect()、shape()、およびcontains() の適切な実装を提供します。

ピクマップは、offset() が返す座標であるアイテムの (0, 0) 座標に描画されます。setOffset() を呼び出すことで、描画オフセットを変更できます。
setTransformationMode() を呼び出すことで、ピクマップの変形モードを設定できます。デフォルトではQt::FastTransformation が使用され、高速ですが滑らかではないスケーリングが行われます。Qt::SmoothTransformation を呼び出すと、ペインター上でQPainter::SmoothPixmapTransform が有効になりますが、その品質はプラットフォームやビューポートによって異なります。通常、QPixmap::scale() を直接呼び出した場合ほど良い結果は得られません。transformationMode() を呼び出すと、そのアイテムの現在の変換モードを取得できます。
関連項目: QGraphicsPathItem 、QGraphicsRectItem 、QGraphicsEllipseItem 、QGraphicsTextItem 、QGraphicsPolygonItem 、QGraphicsLineItem 、およびGraphics View Framework。
メンバ型のドキュメント
enum QGraphicsPixmapItem::ShapeMode
この列挙型は、QGraphicsPixmapItem が形状および不透明領域をどのように計算するかを定義します。
デフォルト値は MaskShape です。
| 定数 | 値 | 説明 |
|---|---|---|
QGraphicsPixmapItem::MaskShape | 0 | 形状は、QPixmap::mask() を呼び出すことで決定されます。この形状には、ピクマップの不透明なピクセルのみが含まれます。ただし、形状の決定がより複雑になるため、他のモードよりも処理速度が遅くなり、より多くのメモリを使用します。 |
QGraphicsPixmapItem::BoundingRectShape | 1 | この形状は、ピクマップの輪郭をトレースすることで決定されます。これは最も高速な形状モードですが、ピクマップ上の透明な領域は考慮されません。 |
QGraphicsPixmapItem::HeuristicMaskShape | 2 | 形状はQPixmap::createHeuristicMask()を呼び出すことで決定されます。パフォーマンスとメモリ消費量はMaskShapeと同様です。 |
[anonymous] enum
仮想関数type()が返す値。
| 定数 | 値 | 説明 |
|---|---|---|
QGraphicsPixmapItem::Type | 7 | グラフィックス・ピクマップ・アイテム |
メンバ関数のドキュメント
[explicit] QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent = nullptr)
QGraphicsPixmapItem を生成します。parent は、QGraphicsItem のコンストラクタに渡されます。
QGraphicsScene::addItem()も参照してください 。
[explicit] QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = nullptr)
pixmap をデフォルトのピクマップとして使用し、QGraphicsPixmapItemを生成します。parent は、QGraphicsItem のコンストラクタに渡されます。
QGraphicsScene::addItem()も参照してください 。
[virtual noexcept] QGraphicsPixmapItem::~QGraphicsPixmapItem()
QGraphicsPixmapItem を削除します。
[override virtual] QRectF QGraphicsPixmapItem::boundingRect() const
QGraphicsItem::boundingRect() const を再実装します。
[override virtual] bool QGraphicsPixmapItem::contains(const QPointF &point) const
QGraphicsItem::contains(const QPointF &point) const を再実装します。
[override virtual] bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const
QGraphicsItem::isObscuredBy (const QGraphicsItem *item)const の再実装です。
QPointF QGraphicsPixmapItem::offset() const
ピクマップ項目のオフセットを返します。このオフセットは、ローカル座標系におけるピクマップの左上隅の位置を定義します。
setOffset()も参照してください 。
[override virtual] QPainterPath QGraphicsPixmapItem::opaqueArea() const
QGraphicsItem::opaqueArea() const を再実装します。
[override virtual] void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
QGraphicsItem::paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)を再実装します。
QPixmap QGraphicsPixmapItem::pixmap() const
アイテムのピクマップを返します。ピクマップが設定されていない場合は、無効なQPixmap を返します。
setPixmap()も参照してください 。
void QGraphicsPixmapItem::setOffset(const QPointF &offset)
ピクマップ項目のオフセットをoffset に設定します。QGraphicsPixmapItem は、左上隅をoffset としてピクマップを描画します。
offset()も参照してください 。
void QGraphicsPixmapItem::setOffset(qreal x, qreal y)
この便利関数は、setOffset(QPointF(x,y)) を呼び出すのと同じです。
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() const を再実装します。
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() const を再実装します。
© 2026 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 the GNU 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.