您可以使用Canvas
元素轻松绘制一条弧线,并控制其起始和结束位置。只需在量表的比例下方组合这个元素。
这是一个示例,演示如何使用0到1之间的值来选择量表有多“满”。
ApplicationWindow {
visible: true
width: 500
height: 500
Canvas {
id: canvas
anchors.fill: parent
rotation: -90
onPaint: {
var c = getContext('2d')
c.clearRect(0, 0, width, height)
c.beginPath()
c.lineWidth = 30
c.strokeStyle = "red"
c.arc(250, 250, 250 - 15, 0, Math.PI * 2 * circ.value)
c.stroke()
}
}
Slider {
id: circ
minimumValue: 0
maximumValue: 1
value: maximumValue / 2
onValueChanged: canvas.requestPaint()
}
}
-Math.PI * 0.5
到Math.PI * 1.5
来处理从3点钟开始的弧线即可。