本页内容

boxgradient2d QML Value Type

提供与 `QCanvasBoxGradient` 匹配的 `boxgradient2d` 类型。更多内容...

Import Statement: import QtCanvas2D
Since: Qt 6.12
Status: Technology preview

此类型处于技术预览阶段,内容可能会有变动。

方法

详细说明

此值类型由QtCanvas2D 导入提供。

另请参阅 QCanvasBoxGradient 。

方法文档

void addColorStop(real offset, string color)

在指定位置offset 的渐变中,添加一个具有给定color 的色阶。0.0 表示渐变一端的偏移量,1.0 表示渐变另一端的偏移量。

例如:

const gradient = ctx.createBoxGradient(50, 50, 100, 100, 20, 10);
gradient.addColorStop(0.0, Qt.rgba(1, 0, 0, 1));
gradient.addColorStop(0.5, "#ff8040");
gradient.addColorStop(1.0, "red");

real feather()

返回盒子渐变的羽化效果。

另请参阅 setFeather()。

real radius()

返回盒式渐变的半径。

另请参阅 setRadius()。

rect rect()

返回盒子渐变的矩形面积。

另请参阅 setRect()。

void setFeather(real feather)

将框形渐变的羽化效果设置为feather 。

另请参阅 feather()。

void setRadius(real radius)

将框形渐变的半径设置为radius 。最大半径为rect()的宽度或高度的一半,以较小者为准。

另请参阅 radius()。

void setRect(x, y, width, height)

将框形渐变的矩形位置设置为 (x,y),大小设置为 (width,height)。

另请参阅 rect()。

void setRect(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.