Rectangle
에 대한 기본 수직선보다 더 구체적인 그래디언트를 갖고 싶습니다. 대각선 효과로 LinearGradient
을 추가하려고 시도하지만 테두리를 덮어 씁니다.QT QML 테두리가있는 사각형에 LinearGradient를 추가하는 방법은 무엇입니까?
이 예제를 고려하십시오. 상단의 세로 그라디언트와 테두리가 Rectangle
입니다. 하단 Rectangle
그래디언트가 경계를 덮어 쓰고 radius
입니다. clip
과 gradient: LinearGradient
을 시도했지만 작동하지 않았습니다. 이에
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.0
ApplicationWindow
{
visible: true
width: 640
height: 480
Column
{
spacing: 20
width: parent.width
Rectangle
{
width: 200
height: 200
border.width: 4
border.color: "#888"
radius: 10
// adds a vertical gradient to button
gradient: Gradient
{
GradientStop
{
position: 0
color: "#eee"
}
GradientStop
{
position: 1
color: "#ccc"
}
}
}
Rectangle
{
width: 200
height: 200
border.width: 4
border.color: "#888"
radius: 10
// try to add diagonal gradient, but overwrites button border
// also can't do, gradient: LinearGradient ?
LinearGradient
{
anchors.fill: parent
start: Qt.point(0,0)
end: Qt.point(parent.width,parent.height)
gradient: Gradient
{
GradientStop
{
position: 0
color: "#eee"
}
GradientStop
{
position: 1
color: "#ccc"
}
}
}
}
}
}
결과 :
I는이 결과가있을 수 있습니다 이유를 볼 수 있지만 어떻게 radius
으로 Rectangle
에 그라데이션 클립을?
감사합니다.
감사합니다. 이것은 대답이다. '반경 '경계선을 고치는 거지. 예를 들어'anchors.margins : rect1.radius'를 추가해야합니다. 그렇지 않으면 작동합니다. 감사. –