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, float feather, float radius = 0.0f) | |
| QCanvasBoxGradient(float x, float y, float width, float height, float feather, float radius = 0.0f) | |
| float | feather() const |
| float | radius() const |
| QRectF | rect() const |
| void | setFeather(float feather) |
| void | setRadius(float radius) |
| void | setRect(float x, float y, float width, float height) |
| void | setRect(const QRectF &rect) |
詳しい説明
ボックスグラデーションは、始点と終点の間で色を補間し、丸みを帯びた矩形状のグラデーションを作成します。setRadius() とsetFeather() で、グラデーションの丸みと柔らかさを制御できます。

以下に簡単な例を示します:
![]() | QRectF rect(20, 20, 160, 160); QCanvasBoxGradient bg(rect, 20, 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。グラデーションの開始色は白 (255, 255, 255)、終了色は透明な黒 (0, 0, 0, 0)。
QCanvasBoxGradient::QCanvasBoxGradient(const QRectF &rect, float feather, float radius = 0.0f)
ボックスグラデーションを作成します。グラデーションの位置とサイズはrect 。グラデーションの羽根はfeather 。グラデーションの半径はradius 。グラデーションの開始色は白 (255, 255, 255) で、終了色は透明な黒 (0, 0, 0, 0) です。
QCanvasBoxGradient::QCanvasBoxGradient(float x, float y, float width, float height, float feather, float radius = 0.0f)
ボックスグラデーションを作成します。グラデーションの位置は (x,y) で、サイズは (width,height) です。 グラデーションの羽根はfeather です。グラデーションの半径はradius 。グラデーションの開始色は白 (255, 255, 255) で、 終了色は透過な黒 (0, 0, 0, 0) です。
float QCanvasBoxGradient::feather() const
ボックスグラデーションの羽根を返します。
setFeather()も参照 ください。
float QCanvasBoxGradient::radius() const
ボックスグラデーションの半径を返します。
setRadius()も参照 。
QRectF QCanvasBoxGradient::rect() const
ボックスグラデーションの矩形領域を返します。
setRect()も参照 ください。
void QCanvasBoxGradient::setFeather(float feather)
ボックスグラデーションのフェザーをfeather に設定します。
feather()も参照 。
void QCanvasBoxGradient::setRadius(float radius)
ボックスグラデーションの半径をradius に設定します。 最大半径はrect() の幅または高さの半分で、どちらが小さいかによって決まります。
radius()も参照 。
void QCanvasBoxGradient::setRect(float x, float y, float width, float height)
ボックスグラデーションの矩形を、位置 (x,y) とサイズ (width,height) に設定します。
rect()も参照してください 。
void QCanvasBoxGradient::setRect(const QRectF &rect)
ボックスグラデーションの矩形をrect に設定します。
これはオーバーロードされた関数です。
© 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.
