Paste P381

QQC2 SpinBox
ActivePublic

Authored by ngraham on May 6 2019, 9:27 PM.
QQC2.SpinBox {
id: updateIntervalSpinBox
Kirigami.FormData.label: i18nc("@label:spinbox", "Update interval:")
// QQC2 SpinBox doesn't support decimal values so we need to go through
// this rigamarole
// See https://doc.qt.io/qt-5/qml-qtquick-controls2-spinbox.html#custom-values
property int decimals: 1
property real realValue: value / 10
from: 1
stepSize: 1
to: 10000
validator: DoubleValidator {
bottom: Math.min(updateIntervalSpinBox.from, updateIntervalSpinBox.to)
top: Math.max(updateIntervalSpinBox.from, updateIntervalSpinBox.to)
}
textFromValue: function(value) {
realValue = Number(value / 10)
return realValue
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text) * 10
}
}