blob: b88636d44e06431d7a24b18c7f0458528ddce001 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import Qt 4.6
Item {
id: Slider; width: 400; height: 16
// value is read/write.
property real value
onValueChanged: { Handle.x = 2 + (value - minimum) * Slider.xMax / (maximum - minimum); }
property real maximum: 1
property real minimum: 1
property int xMax: Slider.width - Handle.width - 4
Rectangle {
id: Container; anchors.fill: parent
border.color: "white"; border.width: 0; radius: 8
gradient: Gradient {
GradientStop { position: 0.0; color: "#66343434" }
GradientStop { position: 1.0; color: "#66000000" }
}
}
Rectangle {
id: Handle; smooth: true
x: Slider.width / 2 - Handle.width / 2; y: 2; width: 30; height: Slider.height-4; radius: 6
gradient: Gradient {
GradientStop { position: 0.0; color: "lightgray" }
GradientStop { position: 1.0; color: "gray" }
}
MouseRegion {
anchors.fill: parent; drag.target: parent
drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: Slider.xMax+2
onPositionChanged: { value = (maximum - minimum) * (Handle.x-2) / Slider.xMax + minimum; }
}
}
}
|