このページでは

QCanvasBoxGradient Class

QCanvasBoxGradient は、ボックスにグラデーションを描画するためのブラシです。詳細...

ヘッダー: #include <QCanvasBoxGradient>
CMake: find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)
target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter)
以下より: Qt 6.11
継承元: QCanvasGradient

パブリック関数

QCanvasBoxGradient()
QCanvasBoxGradient(const QRectF &rect)
QCanvasBoxGradient(qreal x, qreal y, qreal width, qreal height)
QCanvasBoxGradient(const QCanvasBoxGradient &)
QCanvasBoxGradient(QCanvasBoxGradient &&)
~QCanvasBoxGradient()
qreal feather() const
qreal radius() const
QRectF rect() const
void setFeather(qreal feather)
void setRadius(qreal radius)
void setRect(qreal x, qreal y, qreal width, qreal height)
void setRect(const QRectF &rect)
void swap(QCanvasBoxGradient &other)
QCanvasBoxGradient &operator=(QCanvasBoxGradient &&)
QCanvasBoxGradient &operator=(const QCanvasBoxGradient &)

詳細な説明

ボックスグラデーションは、開始点と終了点の間で色を補間し、角が丸い長方形のグラデーションを作成します。setRadius() およびsetFeather() を使用することで、グラデーションの丸みと滑らかさを制御できます。

色、角の半径、縁の滑らかさがそれぞれ異なる、角が丸い長方形のグラデーションが施された4つの正方形

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

濃い青色の丸みを帯びた四角形で、縁に沿って柔らかな黄色の光が漂っている
QRectF rect(20, 20, 160, 160);
QCanvasBoxGradient bg(rect);
bg.setFeather(20);
bg.setRadius(50);
bg.setColorAt(0.0, "#1a2a6c");
bg.setColorAt(0.2, "#fdbb2d");
bg.setColorAt(1.0, QColorConstants::Transparent);
p->setFillStyle(bg);
p->fillRect(rect);

注: QCanvasBoxGradientを使用して角丸長方形を描画する場合 、丸みはパスではなくブラシによって生成されるため、通常はQCanvasPainter::roundRect()よりもQCanvasPainter::rect()を使用する方が望ましいです。これにより、余分な頂点が生成されるのを避け、パフォーマンスが向上します。

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

QCanvasBoxGradient::QCanvasBoxGradient()

デフォルトのボックスグラデーションを作成します。グラデーションの位置は (0, 0)、サイズは (100, 100) です。グラデーションのフェザーは 10.0、グラデーションの半径は 0.0 です。

QCanvasBoxGradient::QCanvasBoxGradient(const QRectF &rect)

ボックスのグラデーションを作成します。グラデーションの位置とサイズは `rect` です。グラデーションのフェザーは 10.0、半径は 0.0 です。

setFeather() およびsetRadius()も参照してください 。

QCanvasBoxGradient::QCanvasBoxGradient(qreal x, qreal y, qreal width, qreal height)

ボックスのグラデーションを作成します。グラデーションの位置は (x,y)、サイズは (width,height) です。グラデーションのフェザーは 10.0、半径は 0.0 です。

setFeather() およびsetRadius()も参照してください 。

[constexpr noexcept default] QCanvasBoxGradient::QCanvasBoxGradient(const QCanvasBoxGradient &)

QCanvasBoxGradient のインスタンスをコピーして生成します。

[constexpr noexcept default] QCanvasBoxGradient::QCanvasBoxGradient(QCanvasBoxGradient &&)

QCanvasBoxGradient のインスタンスをムーブコンストラクトで生成します。

[constexpr noexcept default] QCanvasBoxGradient::~QCanvasBoxGradient()

QCanvasBoxGradient のインスタンスを破棄します。

qreal QCanvasBoxGradient::feather() const

ボックスのグラデーションのフェザーを返します。

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

qreal QCanvasBoxGradient::radius() const

ボックスのグラデーションの半径を返します。

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

QRectF QCanvasBoxGradient::rect() const

ボックスのグラデーションの矩形領域を返します。

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

void QCanvasBoxGradient::setFeather(qreal feather)

ボックスのグラデーションのフェザーを「feather 」に設定します。

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

void QCanvasBoxGradient::setRadius(qreal radius)

ボックスのグラデーションの半径を `radius` に設定します。最大半径は、`rect()` の幅と高さのいずれか小さい方の半分となります。

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

void QCanvasBoxGradient::setRect(qreal x, qreal y, qreal width, qreal height)

ボックスのグラデーションの矩形を、位置(x 、y )およびサイズ(width 、height )に設定します。

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

void QCanvasBoxGradient::setRect(const QRectF &rect)

ボックスのグラデーションの矩形を `rect` に設定します。

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

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

このグラデーションをother と入れ替えます。この操作は非常に高速で、失敗することはありません。

[noexcept default] QCanvasBoxGradient &QCanvasBoxGradient::operator=(QCanvasBoxGradient &&)

other をこのQCanvasBoxGradient インスタンスに割り当てます。

[noexcept default] QCanvasBoxGradient &QCanvasBoxGradient::operator=(const QCanvasBoxGradient &)

other をこのQCanvasBoxGradient インスタンスにコピー・割り当てします。

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