-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomSpinBox.qml
More file actions
26 lines (25 loc) · 777 Bytes
/
Copy pathCustomSpinBox.qml
File metadata and controls
26 lines (25 loc) · 777 Bytes
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
import QtQuick 2.0
import QtQuick.Controls 2.1
Item {
property alias spim: spinbox
property int decimals: 2
property real realValue: 0.0
property real realFrom: -100.0
property real realTo: 100.0
property real realStepSize: 1.0
SpinBox{
property real factor: Math.pow(10, decimals)
id: spinbox
stepSize: realStepSize*factor
value: realValue*factor
to : realTo*factor
from : realFrom*factor
validator: DoubleValidator {
bottom: Math.min(spinbox.from, spinbox.to)*spinbox.factor
top: Math.max(spinbox.from, spinbox.to)*spinbox.factor
}
textFromValue: function(value, locale) {
return parseFloat(value*1.0/factor).toFixed(decimals);
}
}
}