このページでは

QCanvasImagePattern Class

QCanvasImagePattern は画像パターンを描くためのブラシです。詳細...

ヘッダー #include <QCanvasImagePattern>
CMake: find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)
target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter)
以来:Qt 6.11
を継承しています: QCanvasBrush
ステータス技術プレビュー

パブリック関数

QCanvasImagePattern()
QCanvasImagePattern(const QCanvasImage &image)
QCanvasImagePattern(const QCanvasImage &image, const QRectF &rect, float angle = 0.0f, const QColor &tintColor = QColorConstants::White)
QCanvasImagePattern(const QCanvasImage &image, float x, float y, float width, float height, float angle = 0.0f, const QColor &tintColor = QColorConstants::White)
~QCanvasImagePattern()
QCanvasImage image() const
QSizeF imageSize() const
float rotation() const
void setImage(const QCanvasImage &image)
void setImageSize(float width, float height)
void setImageSize(QSizeF size)
void setRotation(float rotation)
void setStartPosition(float x, float y)
void setStartPosition(QPointF point)
void setTintColor(const QColor &color)
QPointF startPosition() const
QColor tintColor() const
operator QVariant() const
bool operator!=(const QCanvasImagePattern &lhs, const QCanvasImagePattern &rhs)
QDataStream &operator<<(QDataStream &stream, const QCanvasImagePattern &pattern)
bool operator==(const QCanvasImagePattern &lhs, const QCanvasImagePattern &rhs)
QDataStream &operator>>(QDataStream &stream, QCanvasImagePattern &pattern)

詳細説明

QCanvasImagePattern は画像パターンを描くためのブラシです。QCanvasImage をパターンとして使用するには、QCanvasPainter::ImageFlag::Repeat のようにいくつかの繰り返しフラグをオンにする必要があります。

以下に簡単な例を示します:

// Setup 2 image patterns
static QImage image1(":/pattern2.png");
static QImage image2(":/pattern3.png");
auto flags = QCanvasPainter::ImageFlag::Repeat |
             QCanvasPainter::ImageFlag::GenerateMipmaps;
QCanvasImage bg1 = painter.addImage(image1, flags);
QCanvasImage bg2 = painter.addImage(image2, flags);
QCanvasImagePattern ip1(bg1, 0, 0, 64, 64);
QCanvasImagePattern ip2(bg2, 0, 0, 32, 32);
// Fill and stroke round rectangle with
// these image pattern brushes.
painter.beginPath();
painter.roundRect(50, 50, 180, 180, 40);
painter.setFillStyle(ip1);
painter.setStrokeStyle(ip2);
painter.fill();
painter.setLineWidth(20);
painter.stroke();

注意: イメージパターンを使用する場合、イメージはしばしば小さくスケーリングされ、滑らかなパターンを持つために、使用するQCanvasImageQCanvasPainter::ImageFlag::GenerateMipmaps を設定すると便利です。

メンバー関数ドキュメント

QCanvasImagePattern::QCanvasImagePattern()

デフォルトの画像パターンを構築します。画像は設定されませんので、このコンストラクタの後にsetImage() を使用してください。パターン開始位置は (0, 0)、パターンサイズは (100, 100)。パターンの角度は 0.0、色合いは白(着色なし)。

setImage()も参照

QCanvasImagePattern::QCanvasImagePattern(const QCanvasImage &image)

画像パターンを構築します。パターンはimage を使います。image は通常、少なくともQCanvasPainter::ImageFlag::Repeat フラグがセットされている必要があることに注意してください。パターン開始位置は (0, 0)、パターンサイズは (100, 100)。パターン角度は 0.0、色合いは白(着色なし)。

QCanvasImagePattern::QCanvasImagePattern(const QCanvasImage &image, const QRectF &rect, float angle = 0.0f, const QColor &tintColor = QColorConstants::White)

画像パターンを構築します。パターンはimage を使います。image は通常、少なくともQCanvasPainter::ImageFlag::Repeat フラグがセットされている必要があることに注意してください。パターン画像の位置とサイズはrect で定義します。パターン角度はangle で、色合いはtintColor です。

QCanvasImagePattern::QCanvasImagePattern(const QCanvasImage &image, float x, float y, float width, float height, float angle = 0.0f, const QColor &tintColor = QColorConstants::White)

画像パターンを構築します。パターンはimage を使います。通常、image には少なくともQCanvasPainter::ImageFlag::Repeat フラグが設定されていなければならないことに注意してください。パターン画像の開始位置は (x,y) で、パターンサイズは (width,height) です。パターンの角度はangle で、色合いはtintColor です。

[noexcept] QCanvasImagePattern::~QCanvasImagePattern()

イメージパターンを破壊する。

QCanvasImage QCanvasImagePattern::image() const

パターンの画像を返します。

setImage()も参照ください

QSizeF QCanvasImagePattern::imageSize() const

単一の画像のサイズを pattern で返します。

setImageSize()も参照

float QCanvasImagePattern::rotation() const

パターンの回転をラジアン単位で返します。

setRotation()も参照

void QCanvasImagePattern::setImage(const QCanvasImage &image)

パターンの画像をimage に設定します。 注: 画像パターンで使用する場合、画像には通常Repeat フラグが設定されている必要があります。

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

void QCanvasImagePattern::setImageSize(float width, float height)

パターン内の単一画像のサイズを (width,height) に設定する。

imageSize()も参照

void QCanvasImagePattern::setImageSize(QSizeF size)

パターン内の単一画像のサイズをsize に設定する。

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

void QCanvasImagePattern::setRotation(float rotation)

パターンの回転をrotation にラジアン単位で設定する。回転は画像startPosition() を中心に行われます。デフォルト値は0.0 で、 画像は回転しません。

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

void QCanvasImagePattern::setStartPosition(float x, float y)

画像パターンの開始位置を (x,y) に設定する。開始位置とは、パターン内の画像の左上隅を意味します。パ タ ーンは、 こ こ か ら すべての位置へ拡張 さ れます (imageRepeat フ ラ グが設定 さ れてい る 場合)。

startPosition()も参照

void QCanvasImagePattern::setStartPosition(QPointF point)

画像パ タ ーン の開始位置をpoint に設定 し ます。 開始位置 と は、 パ タ ーン内の画像の左上隅を意味 し ます。(画像Repeat フラグが設定されている場合) パターンはここからすべての位置に拡張されます。

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

void QCanvasImagePattern::setTintColor(const QColor &color)

パターンの色合いをcolor に設定します。パターン画像の色は、シェーダ内でこの色合いと掛け合わされます。デフォルト値は白で、色合いはありません。

注意: アルファをグローバルに設定するには、QCanvasPainter::setGlobalAlpha() を使用します。

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

QPointF QCanvasImagePattern::startPosition() const

画像パターンの開始点を返す。

setStartPosition()も参照

QColor QCanvasImagePattern::tintColor() const

パターンの色合いを返します。

setTintColor()も参照

QCanvasImagePattern::operator QVariant() const

画像パターンをQVariant として返す。

関連する非会員

[noexcept] bool operator!=(const QCanvasImagePattern &lhs, const QCanvasImagePattern &rhs)

画像パターンlhsrhs と異なる場合はtrue を返し、そうでない場合はfalse を返す。

operator==()も参照

QDataStream &operator<<(QDataStream &stream, const QCanvasImagePattern &pattern)

与えられたpattern を与えられたstream に書き込み、stream への参照を返します。

Qt データ型のシリアライズも参照してください

[noexcept] bool operator==(const QCanvasImagePattern &lhs, const QCanvasImagePattern &rhs)

画像パターンlhsrhs と等しければtrue を返し、そうでなければfalse を返す。

operator!=()も参照

QDataStream &operator>>(QDataStream &stream, QCanvasImagePattern &pattern)

与えられたstream から与えられたpattern を読み込み、stream への参照を返します。

Qt データ型のシリアライズも参照してください

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