Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual
Page 257

KTD-S0057-I
Page 253 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
File Slider.qml (header with Qt
TM
license see 'main.cpp'):
import QtQuick 1.0
Item
{
id:
slider
width:
400
height:
16
// value is read / write.
property real value: 1
onValueChanged:
updatePos
()
property real maximum: 1
property real minimum: 1
property int xMax: width - handle.width - 4
onXMaxChanged: updatePos ()
onMinimumChanged: updatePos ()
function updatePos ()
{
if (maximum > minimum)
{
var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum)
pos = Math.min (pos, width - handle.width - 2)
pos = Math.max (pos, 2)
handle.x = pos
}
else
{
handle.x = 2
}
}
Rectangle
{
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"
}
}
}