QGraphicsPixmapItem Class

QGraphicsPixmapItem クラスは、QGraphicsScene に追加できる pixmap アイテムを提供します

ヘッダー #include <QGraphicsPixmapItem>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
継承: 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

詳しい説明

アイテムの pixmap を設定するには、QPixmap を QGraphicsPixmapItem のコンストラクタに渡すか、setPixmap() 関数を呼び出します。pixmap() 関数は現在の pixmap を返します。

QGraphicsPixmapItem は、pixmap のオプションのアルファ マスクを使用して、boundingRect()、shape()、contains() の合理的な実装を提供します。

pixmap は、offset() が返すアイテムの (0, 0) 座標で描画されます。描画オフセットは、setOffset ()を呼び出すことで変更できます。

setTransformationMode() を呼び出すと、pixmap の変換モードを設定できます。デフォルトでは、Qt::FastTransformation が使用され、高速で滑らかでないスケーリングが提供されます。Qt::SmoothTransformation を使用すると、ペインタ上でQPainter::SmoothPixmapTransform が有効になり、その品質はプラットフォームとビューポートに依存します。結果は通常、QPixmap::scale() を直接呼び出すほど良くありません。アイテムの現在の変換モードを取得するには、transformationMode() を呼び出します。

QGraphicsPathItem,QGraphicsRectItem,QGraphicsEllipseItem,QGraphicsTextItem,QGraphicsPolygonItem,QGraphicsLineItem, およびGraphics View Frameworkも参照のこと

メンバ型ドキュメント

enum QGraphicsPixmapItem::ShapeMode

この列挙型は、QGraphicsPixmapItem の形状と不透明領域の計算方法を記述します。

デフォルト値は MaskShape です。

定数説明
QGraphicsPixmapItem::MaskShape0形状はQPixmap::mask() を呼び出すことによって決定される。この形状は、pixmapの不透明なピクセルのみを含みます。しかし、この形状はより複雑であるため、他のモードよりも遅くなることがあり、より多くのメモリを使用します。
QGraphicsPixmapItem::BoundingRectShape1シェイプはpixmapのアウトラインをトレースして決定される。これは最も高速なシェイプモードだが、pixmap上の透明な領域は考慮されない。
QGraphicsPixmapItem::HeuristicMaskShape2形状は、QPixmap::createHeuristicMask ()を呼び出すことによって決定される。性能とメモリ消費量は MaskShape と同様です。

enum QGraphicsPixmapItem::anonymous

仮想type() 関数が返す値。

定数説明
QGraphicsPixmapItem::Type7グラフィックスの pixmap アイテム

メンバ関数ドキュメント

[explicit] QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent = nullptr)

QGraphicsPixmapItem を構築します。parentQGraphicsItem のコンストラクタに渡されます。

QGraphicsScene::addItem()も参照してください

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

pixmap をデフォルトの pixmap として QGraphicsPixmapItem を構築します。parentQGraphicsItem のコンストラクタに渡されます。

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

pixmap の左上隅の点を定義する pixmap アイテムのオフセットをローカル座標で返します。

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

アイテムの pixmap、または pixmap が設定されていない場合は無効なQPixmap を返します。

setPixmap()も参照してください

void QGraphicsPixmapItem::setOffset(const QPointF &offset)

pixmap アイテムのオフセットをoffset に設定します。QGraphicsPixmapItem は、その左上隅にoffset を使って pixmap を描画します。

offset()も参照してください

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

この便宜関数は、setOffset(QPointF(x,y)) を呼び出すのと等価である。

void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap)

アイテムの pixmap をpixmap に設定します。

pixmap()も参照してください

void QGraphicsPixmapItem::setShapeMode(QGraphicsPixmapItem::ShapeMode mode)

アイテムのシェイプモードをmode に設定します。 シェイプモードは、QGraphicsPixmapItem がどのようにシェイプを計算するかを記述します。デフォルトのモードはMaskShape です。

shapeMode() およびShapeModeも参照してください

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

pixmap アイテムの変換モードをmode に設定し、アイテムの更新をトグルします。デフォルトのモードはQt::FastTransformation で、スムージングなしで素早く変形します。

Qt::SmoothTransformation はペインター上で を有効にし、品質はプラットフォームとビューポートに依存します。結果は通常、QPixmap::scale() を直接呼び出すほど良くありません。QPainter::SmoothPixmapTransform

transformationMode()も参照してください

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

再実装:QGraphicsItem::shape() const.

QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode() const

アイテムの形状モードを返します。シェイプモードは、QGraphicsPixmapItem がどのようにシェイプを計算するかを表します。デフォルトのモードはMaskShape です。

setShapeMode() およびShapeModeも参照して ください。

Qt::TransformationMode QGraphicsPixmapItem::transformationMode() const

pixmap の変換モー ド を返 し ます。デフォル ト のモー ド はQt::FastTransformation で、 スムーシ ングを行わず、 素早く変換 し ます。

setTransformationMode()も参照して ください。

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

再実装:QGraphicsItem::type() const.

© 2025 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.