QPicture Class

QPictureクラスは、QPainter コマンドを記録・再生するペイント・デバイスです。詳細...

ヘッダー #include <QPicture>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
継承: QPaintDevice

パブリック関数

QPicture(int formatVersion = -1)
QPicture(const QPicture &pic)
virtual ~QPicture()
QRect boundingRect() const
const char *data() const
bool isNull() const
bool load(const QString &fileName)
bool load(QIODevice *dev)
bool play(QPainter *painter)
bool save(const QString &fileName)
bool save(QIODevice *dev)
void setBoundingRect(const QRect &r)
virtual void setData(const char *data, uint size)
uint size() const
void swap(QPicture &other)
QPicture &operator=(QPicture &&other)
QPicture &operator=(const QPicture &p)
QDataStream &operator<<(QDataStream &s, const QPicture &r)
QDataStream &operator>>(QDataStream &s, QPicture &r)

詳細説明

ピクチャは、プラットフォームに依存しないフォーマットでIOデバイスへのペインターコマンドをシリアライズします。これらはメタファイルと呼ばれることもあります。

Qt のピクチャは独自のバイナリフォーマットを使用します。多くのウィンドウシステムのネイティブなピクチャ(メタファイル)フォーマットとは異なり、Qt のピクチャはその内容に関して制限がありません。ウィジェットやpixmapに描画できるもの(フォント、pixmap、リージョン、変換されたグラフィックなど)はすべてピクチャに保存できます。

QPictureは、解像度に依存しません。つまり、QPictureは、異なるデバイス(例えば、svg、pdf、ps、プリンタ、スクリーン)で同じように表示することができます。これは例えば、WYSIWYG印刷プレビューに必要です。QPictureはデフォルトのシステムdpiで動作し、ウィンドウシステムによる解像度の違いに合わせてペインターを拡大縮小します。

画像を記録する方法の例:

QPicture picture;
QPainter painter;
painter.begin(&picture);           // paint in picture
painter.drawEllipse(10,20, 80,70); // draw an ellipse
painter.end();                     // painting done
picture.save("drawing.pic");       // save picture

ペインターコマンドのリストは、QPainter::begin() 関数を呼び出すたびにリセットされることに注意してください。

絵を再生する例:

QPicture picture;
picture.load("drawing.pic");           // load picture
QPainter painter;
painter.begin(&myImage);               // paint in myImage
painter.drawPicture(0, 0, picture);    // draw the picture at (0,0)
painter.end();                         // painting done

play() を使っても絵を描くことができる。例えば、size()、isNull()、boundingRect() のように、絵に関する基本的なデータがいくつか用意されている。

QMovieも参照のこと

メンバ関数ドキュメント

[explicit] QPicture::QPicture(int formatVersion = -1)

空のピクチャを構築します。

formatVersion パラメータを使用すると、以前のバージョンの Qt でコンパイルされたアプリケーションで読み込める QPicture を作成できます。

デフォルトのformatVersionは、現在のリリースを示す-1であることに注意してください。つまり、Qt 4.0のformatVersion 7は、デフォルトのformatVersion -1と同じです。

Qt 4.0では、以前のバージョンのQtで生成されたピクチャの読み込みはサポートされていません。

QPicture::QPicture(const QPicture &pic)

pic のコピーを構築する。

このコンストラクタは暗黙の共有のおかげで高速です。

[virtual noexcept] QPicture::~QPicture()

写真を破壊する。

QRect QPicture::boundingRect() const

ピクチャの外接矩形を返すか、ピクチャにデータがない場合は無効な矩形を返します。

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

const char *QPicture::data() const

ピクチャデータへのポインタを返します。このポインタは、次にこのピクチャに対して nononst 関数が呼び出されるまで有効である。ピクチャにデータがない場合、返されるポインタは 0 である。

setData()、size()、isNull()も参照

bool QPicture::isNull() const

画像にデータが含まれていない場合はtrue を返し、そうでない場合は false を返します。

bool QPicture::load(const QString &fileName)

fileName で指定されたファイルから画像を読み込み、成功した場合は true を返し、失敗した場合は画像を無効にしてfalse を返す。

save()も参照

bool QPicture::load(QIODevice *dev)

これはオーバーロードされた関数である。

dev はロードに使用するデバイスです。

bool QPicture::play(QPainter *painter)

painter を使って画像を再生し、成功すればtrue を返し、そうでなければfalse を返す。

この関数は、(x, y) = (0, 0) でQPainter::drawPicture() と全く同じことを行う。

注意: この関数では、ペインターの状態は保存されません。

bool QPicture::save(const QString &fileName)

fileName で指定されたファイルに画像を保存し、成功した場合は true を返し、失敗した場合はfalse を返す。

load()も参照のこと

bool QPicture::save(QIODevice *dev)

これはオーバーロードされた関数である。

dev は保存に使用するデバイスです。

void QPicture::setBoundingRect(const QRect &r)

画像の外接矩形をr に設定します。 自動計算された値が上書きされます。

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

[virtual] void QPicture::setData(const char *data, uint size)

data およびsize から直接ピクチャーデータを設定する。この関数は入力データをコピーする。

data() およびsize()も参照のこと

uint QPicture::size() const

画像データのサイズを返す。

data()も参照

[noexcept] void QPicture::swap(QPicture &other)

この写真をother と入れ替える。この操作は非常に速く、失敗することはない。

[noexcept] QPicture &QPicture::operator=(QPicture &&other)

Move-other をこのQPicture インスタンスに割り当てる。

QPicture &QPicture::operator=(const QPicture &p)

このピクチャにピクチャp を割り当て、このピクチャへの参照を返します。

関連する非会員

QDataStream &operator<<(QDataStream &s, const QPicture &r)

画像r をストリームs に書き込み、ストリームへの参照を返します。

QDataStream &operator>>(QDataStream &s, QPicture &r)

ストリームs から picturer に画像を読み込み、ストリームへの参照を返す。

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