我需要在项目中沿x轴应用Linear Gradient。但它似乎不起作用。即使使用最简单的代码,也就是来自Linear Gradient的Qt文档,它并没有显示预期的输出。
这是我的代码。
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Item {
width: 300
height: 300
LinearGradient {
anchors.fill: parent
end: Qt.point(300, 0)
start: Qt.point(0, 0)
gradient: Gradient {
GradientStop { position: 0.0; color: "white" }
GradientStop { position: 1.0; color: "black" }
}
}
}}
我的代码产生了这个输出。
任何人都知道发生了什么。请帮忙。提前谢谢。
答案 0 :(得分:1)
很奇怪,我正在使用2.5版本,我有正确的输出...... 无论如何,您仍然可以垂直定义渐变并应用旋转
end: Qt.point(0, 300)
start: Qt.point(0, 0)
rotation: -90