このページでは

QCanvasGridPattern Class

QCanvasGridPattern はグリッドパターンを描くためのブラシです。詳細...

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

パブリック関数

QCanvasGridPattern()
QCanvasGridPattern(const QRectF &rect, const QColor &lineColor = QColorConstants::White, const QColor &backgroundColor = QColorConstants::Black, float lineWidth = 1.0f, float feather = 1.0f, float angle = 0.0f)
QCanvasGridPattern(float x, float y, float width, float height, const QColor &lineColor = QColorConstants::White, const QColor &backgroundColor = QColorConstants::Black, float lineWidth = 1.0f, float feather = 1.0f, float angle = 0.0f)
~QCanvasGridPattern()
QColor backgroundColor() const
QSizeF cellSize() const
float feather() const
QColor lineColor() const
float lineWidth() const
float rotation() const
void setBackgroundColor(const QColor &color)
void setCellSize(float width, float height)
void setCellSize(QSizeF size)
void setFeather(float feather)
void setLineColor(const QColor &color)
void setLineWidth(float width)
void setRotation(float rotation)
void setStartPosition(float x, float y)
void setStartPosition(QPointF point)
QPointF startPosition() const
operator QVariant() const
bool operator!=(const QCanvasGridPattern &lhs, const QCanvasGridPattern &rhs)
QDataStream &operator<<(QDataStream &stream, const QCanvasGridPattern &pattern)
bool operator==(const QCanvasGridPattern &lhs, const QCanvasGridPattern &rhs)
QDataStream &operator>>(QDataStream &stream, QCanvasGridPattern &pattern)

詳細説明

QCanvasGridPattern は、グリッド パターンとバー パターンを描くためのブラシです。

簡単な例を示します:

// Rotated grid into background
QRectF rect(20, 20, 180, 180);
QCanvasGridPattern gp1(rect, "#DBEB00", "#373F26");
gp1.setCellSize(16, 16);
gp1.setStartPosition(rect.topLeft());
gp1.setLineWidth(2.0f);
gp1.setRotation(M_PI / 4);
gp1.setFeather(5.0f);
painter.setFillStyle(gp1);
painter.fillRect(rect);
// Rounded rectangle, stroked with
// grid pattern for dashes.
float strokeW = 10;
QRectF rect2(40, 40, 140, 140);
QCanvasGridPattern gp2;
gp2.setLineColor(Qt::transparent);
gp2.setBackgroundColor(Qt::white);
gp2.setStartPosition(rect2.x() - strokeW,
                     rect2.y() - strokeW);
gp2.setCellSize(40, 40);
gp2.setLineWidth(strokeW);
painter.setLineWidth(8);
painter.setStrokeStyle(gp2);
painter.beginPath();
painter.roundRect(rect2, 10);
painter.stroke();

メンバ関数ドキュメント

QCanvasGridPattern::QCanvasGridPattern()

デフォルトのグリッドパターンを構築する。パターン開始位置は (0, 0)、パターンサイズは (100, 100)。パターンの角度は 0.0、グリッド線の色は白、背景色は黒。

QCanvasGridPattern::QCanvasGridPattern(const QRectF &rect, const QColor &lineColor = QColorConstants::White, const QColor &backgroundColor = QColorConstants::Black, float lineWidth = 1.0f, float feather = 1.0f, float angle = 0.0f)

グリッドパターンを構築します。パターンの開始位置とサイズはrect で定義します。グリッド線の色はlineColor で、背景色はbackgroundColor です。グリッド線の幅はlineWidth 、フェザー(アンチエイリアス)はfeather 、角度はangle

QCanvasGridPattern::QCanvasGridPattern(float x, float y, float width, float height, const QColor &lineColor = QColorConstants::White, const QColor &backgroundColor = QColorConstants::Black, float lineWidth = 1.0f, float feather = 1.0f, float angle = 0.0f)

グリッドパターンを構築する。パターン開始位置は (x,y) で、パターンサイズは (width,height) です。グリッド線の色はlineColor で、背景色はbackgroundColor です。パ タ ーン角度はangle

[noexcept] QCanvasGridPattern::~QCanvasGridPattern()

グリッドパターンを破壊する。

QColor QCanvasGridPattern::backgroundColor() const

パターングリッドの背景色を返します。

setBackgroundColor()も参照 ください。

QSizeF QCanvasGridPattern::cellSize() const

グリッドパターン内の 1 つのセルのサイズを返します。

setCellSize()も参照

float QCanvasGridPattern::feather() const

パターンの羽根をピクセル単位で返します。

setFeather()も参照

QColor QCanvasGridPattern::lineColor() const

パターングリッドの線の色を返します。

setLineColor()も参照 ください。

float QCanvasGridPattern::lineWidth() const

グリッドパターンのストローク線の幅を返します。

setLineWidth()も参照

float QCanvasGridPattern::rotation() const

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

setRotation()も参照

void QCanvasGridPattern::setBackgroundColor(const QColor &color)

パターングリッドの背景色をcolor に設定します。 デフォルト値は黒です。

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

void QCanvasGridPattern::setCellSize(float width, float height)

グリッドパターンの1セルの大きさをwidth,height に設定する。width が0 のとき、横棒は描かれない。height が0 のとき、縦バーは描画されない。デフォル ト 値は(10, 10)

cellSize()も参照

void QCanvasGridPattern::setCellSize(QSizeF size)

グリッドパターンの1セルの大きさをsize に設定する。 width が0 のとき、横棒は描かれない。height が0 の場合、 縦バーは描画されない。デフォルト値は(10, 10) です。

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

void QCanvasGridPattern::setFeather(float feather)

パターンフェザーをfeather にピクセル単位で設定します。デフ ォル ト 値は1.0 で、 シ ン グル ピ クセルのア ン タ イ ア リ ア ス を意味 し ます。

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

void QCanvasGridPattern::setLineColor(const QColor &color)

パ タ ーング リ ッ ド 線の色をcolor に設定 し ます。 デフ ォル ト 値は白です。

lineColor()も参照

void QCanvasGridPattern::setLineWidth(float width)

グ リ ッ ド パ タ ーン内の描線の幅をwidth に設定 し ます。 デフ ォル ト 値は1.0 です。

lineWidth()も参照

void QCanvasGridPattern::setRotation(float rotation)

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

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

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

グリッドパターンの開始位置を (x,y) に設定する。開始位置とは、パターン内のグリッドの左上隅を意味する。パターンはここからすべての位置に拡張されます。デフォルト値は(0.0, 0.0)

startPosition()も参照

void QCanvasGridPattern::setStartPosition(QPointF point)

グリッドパターンの開始位置をpoint に設定します。 開始位置とは、パターン内のグリッドの左上隅を意味します。パターンはここからすべての位置に拡張されます。デフォルト値は(0.0, 0.0) です。

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

QPointF QCanvasGridPattern::startPosition() const

グリッドパターンの開始点を返します。

setStartPosition()も参照

QCanvasGridPattern::operator QVariant() const

グリッドパターンをQVariant として返す。

関連する非会員

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

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

operator==()も参照

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

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

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

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

グリッドパターンlhsrhs と等しければtrue を返し、そうでなければfalse を返す。

operator!=()も参照

QDataStream &operator>>(QDataStream &stream, QCanvasGridPattern &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.