Skip to content

Prefix and Suffix properties for MLDoubleSpinBox #1

Open
@romainreignier

Description

@romainreignier

Your implementation of the DoubleSpinBox for Qt Quick Controls 2 is very interesting. Thanks!
But in order to port code using Qt Quick Controls 1, one would need the support for the prefix and suffix properties.
As mentioned in the doc: prefix and suffix.

I have added it to the floating point SpinBox example from Qt Quick Controls 2 doc like this:

    property string prefix: ''
    property string suffix: ''
    
    [...]

    textFromValue: function(value, locale) {
        return prefix + Number(value / 100).toLocaleString(locale, 'f', decimals) + suffix
    }

    valueFromText: function(text, locale) {
        var numberStr = text.replace(suffix, '').replace(prefix, '');
        return Number.fromLocaleString(locale, numberStr) * 100
    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions