线性渐变 QML 类型
绘制线性渐变。 更多...
| 导入声明 | import Qt5Compat.GraphicalEffects | 
| 自 | QtGraphicalEffects 1.0 | 
| 继承 | 
属性
详细描述
渐变由两种或多种颜色组成,这些颜色融合在一起。颜色从给定的起点开始,到给定的终点结束。
| 应用效果 | 
|---|
| 
 | 
示例
以下示例显示如何应用该效果。
import QtQuick import Qt5Compat.GraphicalEffects Item { width: 300 height: 300 LinearGradient { anchors.fill: parent start: Qt.point(0, 0) end: Qt.point(0, 300) gradient: Gradient { GradientStop { position: 0.0; color: "white" } GradientStop { position: 1.0; color: "black" } } } }
属性文档
| cached : bool | 
此属性允许将效果输出像素缓存,以提高渲染性能。
每当源或效果属性更改时,缓存中的像素必须更新。内存消耗增加,因为需要一个额外的内存缓冲区来存储效果输出。
当源或效果属性进行动画处理时,建议禁用缓存。
默认情况下,该属性设置为 false。
| end : variant | 
| gradient : Gradient | 
渐变由两种或多种颜色组成,这些颜色无缝融合。颜色作为一组 GradientStop 子项指定,其中每个子项定义渐变从 0.0 到 1.0 的位置和一个颜色。每个 GradientStop 的位置由位置属性定义,而颜色由颜色属性定义。
| 不同渐变值的输出示例 | ||
|---|---|---|
| 
 | 
 | 
 | 
| gradient Gradient {
  GradientStop {
     position: 0.000
     color: Qt.rgba(1, 0, 0, 1)
  }
  GradientStop {
     position: 0.167
     color: Qt.rgba(1, 1, 0, 1)
  }
  GradientStop {
     position: 0.333
     color: Qt.rgba(0, 1, 0, 1)
  }
  GradientStop {
     position: 0.500
     color: Qt.rgba(0, 1, 1, 1)
  }
  GradientStop {
     position: 0.667
     color: Qt.rgba(0, 0, 1, 1)
  }
  GradientStop {
     position: 0.833
     color: Qt.rgba(1, 0, 1, 1)
  }
  GradientStop {
     position: 1.000
     color: Qt.rgba(1, 0, 0, 1)
  }
} | gradient Gradient {
  GradientStop {
    position: 0.0
    color: "#F0F0F0"
  }
  GradientStop {
    position: 0.5
    color: "#000000"
  }
  GradientStop {
    position: 1.0
    color: "#F0F0F0"
  }
} | gradient Gradient {
  GradientStop {
    position: 0.0
    color: "#00000000"
  }
  GradientStop {
    position: 1.0
    color: "#FF000000"
  }
} | 
| start: Qt.point(0, 0) | start: Qt.point(0, 0) | start: Qt.point(0, 0) | 
| end: Qt.point(300, 300) | end: Qt.point(300, 300) | end: Qt.point(300, 300) | 
| source : variant | 
| start : variant | 
© 2024Qt公司。此处包含的文档贡献的版权归各自的拥有者。此处提供的文档是根据自由软件基金会发布的GNU自由文档许可协议版本1.3的条款许可的。Qt及其相应商标为芬兰及其在全球的其他国家的Qt公司商标。所有其他商标均为各自所有者的财产。











