| 1 |
import QtQuick 2.0 |
| 2 |
import QtQuick.Controls 2.1 // requires Qt 5.7 or higher |
| 3 |
|
| 4 |
|
| 5 |
Rectangle { |
| 6 |
width: 600; height: 400; |
| 7 |
anchors.fill: parent |
| 8 |
color: "lightgrey" |
| 9 |
|
| 10 |
Slider { |
| 11 |
x: 5; y:5 ; |
| 12 |
width: 100; //height: 10; |
| 13 |
|
| 14 |
} |
| 15 |
|
| 16 |
Button { |
| 17 |
x: 146; y: 10 |
| 18 |
width: 100 |
| 19 |
height: 30 |
| 20 |
text: "Press" |
| 21 |
checkable: true |
| 22 |
onCheckedChanged: console.log(checked) |
| 23 |
} |
| 24 |
|
| 25 |
Dial { |
| 26 |
x: 289 |
| 27 |
y: 20 |
| 28 |
width: 81 |
| 29 |
height: 86 |
| 30 |
from: 0 |
| 31 |
to: 2 |
| 32 |
onValueChanged: console.log("Value:" + value) |
| 33 |
onPositionChanged: { |
| 34 |
var v = from + position*(to-from) |
| 35 |
dialvalue.text = v.toFixed(4) |
| 36 |
} |
| 37 |
|
| 38 |
} |
| 39 |
|
| 40 |
Label { |
| 41 |
id: dialvalue |
| 42 |
x: 312 |
| 43 |
y: 112 |
| 44 |
text: qsTr("0") |
| 45 |
font.pointSize: 24 |
| 46 |
} |
| 47 |
|
| 48 |
SpinBox { |
| 49 |
id: spinbox |
| 50 |
from: 0 |
| 51 |
value: 110 |
| 52 |
to: 100 * 100 |
| 53 |
stepSize: 1 |
| 54 |
anchors.centerIn: parent |
| 55 |
|
| 56 |
property int decimals: 2 |
| 57 |
property real realValue: value / 100 |
| 58 |
|
| 59 |
validator: DoubleValidator { |
| 60 |
bottom: Math.min(spinbox.from, spinbox.to) |
| 61 |
top: Math.max(spinbox.from, spinbox.to) |
| 62 |
} |
| 63 |
|
| 64 |
textFromValue: function(value, locale) { |
| 65 |
return Number(value / 100).toLocaleString(locale, 'f', spinbox.decimals) |
| 66 |
} |
| 67 |
|
| 68 |
valueFromText: function(text, locale) { |
| 69 |
return Number.fromLocaleString(locale, text) * 100 |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
} |