是否可以在QML中对文本应用颜色渐变?如果是这样,怎么办?如果没有,那么达到相同效果的可接受方法是什么?
最佳答案
您可以使用LinearGradient QML类型。
import QtQuick 2.4
import QtQuick.Window 2.2
import QtGraphicalEffects 1.0
Window
{
visible: true
height: 500
width: 500
Text {
id: text
font.pointSize: 55
anchors.centerIn: parent
text: "Hello World!"
visible: false
}
LinearGradient {
anchors.fill: text
source: text
gradient: Gradient {
GradientStop { position: 0; color: "yellow" }
GradientStop { position: 1; color: "red" }
}
}
}
关于qt - 是否可以在QML中对文本应用颜色渐变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29378898/