- Qt 6.11
- Qt Quick Controls
- QML Types
- DoubleSpinBox
- Qt 6.11.0 Reference Documentation

# DoubleSpinBox QML Type

Allows the user to select from a set of preset floating-point values. More...

Import Statement: | `import QtQuick.Controls`
Since: | Qt 6.11
Inherits: | Control

- List of all members, including inherited members

## Properties

- decimals : int
- displayText : string
- down
  - down.hovered : bool
  - down.implicitIndicatorHeight : real
  - down.implicitIndicatorWidth : real
  - down.indicator : Item
  - down.pressed : bool
- editable : bool
- from : double
- inputMethodComposing : bool
- inputMethodHints : flags `(since QtQuick.Controls 2.2 (Qt 5.9))`
- stepSize : double
- textFromValue : function
- to : int
- up
  - up.hovered : bool
  - up.implicitIndicatorHeight : real
  - up.implicitIndicatorWidth : real
  - up.indicator : Item
  - up.pressed : bool
- validator : Validator
- value : double
- valueFromText : function
- wrap : bool `(since QtQuick.Controls 2.3 (Qt 5.10))`

## Signals

- valueModified()

## Methods

- void decrease()
- void increase()

## Detailed Description

DoubleSpinBox is similar to SpinBox, except that it supports double values rather than integer. The user can choose a value by clicking the up or down indicator buttons, or by pressing up or down on the keyboard. Optionally, DoubleSpinBox can be also made editable, so the user can enter a text value in the input field.

By default, DoubleSpinBox provides discrete values in the range of `[0.00-99.99]` with a stepSize of `1.0`.

     DoubleSpinBox {
         id: doubleSpinBox
         from: 0
         value: 1.1
         to: 100
         stepSize: Math.pow(10, -decimals)
         decimals: 2
         editable: true
         anchors.centerIn: parent
     }

See also SpinBox, Tumbler, Customizing DoubleSpinBox, and Focus Management in Qt Quick Controls.

## Property Documentation

### decimals : int

This property holds how many decimals the spinbox will use for displaying and interpreting doubles.

The default value is `2`.

Changing the value of this property may affect from, to and value.

Warning: The maximum value for decimals is `DBL_MAX_10_EXP + DBL_DIG` (`323`) because of the limitations of the double type.

### displayText : string `[read-only]`

This property holds the textual value of the spinbox.

The value of the property is based on textFromValue and locale, and equal to:

     let text = spinBox.textFromValue(spinBox.value, spinBox.decimals, spinBox.locale)

See also textFromValue.

### down group

### down.hovered : bool

### down.implicitIndicatorHeight : real

### down.implicitIndicatorWidth : real

### down.indicator : Item

### down.pressed : bool

This grouped property holds the down indicator item and its associated properties.

See also decrease().

### editable : bool

This property holds whether the spinbox is editable. The default value is `false`.

See also validator.

### from : double

This property holds the starting value for the range. The default value is `0.0`.

See also to and value.

### inputMethodComposing : bool `[read-only]`

This property holds whether an editable spin box has partial text input from an input method.

While it is composing, an input method may rely on mouse or key events from the spin box to edit or commit the partial text. This property can be used to determine when to disable event handlers that may interfere with the correct operation of an input method.

### inputMethodHints : flags `[since QtQuick.Controls 2.2 (Qt 5.9)]`

This property provides hints to the input method about the expected content of the spin box and how it should operate.

The default value is `Qt.ImhDigitsOnly`.

The value is a bit-wise combination of flags or `Qt.ImhNone` if no hints are set.

Flags that alter behavior are:

- Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords.
- Qt.ImhSensitiveData - Typed text should not be stored by the active input method in any persistent storage like predictive user dictionary.
- Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case when a sentence ends.
- Qt.ImhPreferNumbers - Numbers are preferred (but not required).
- Qt.ImhPreferUppercase - Upper case letters are preferred (but not required).
- Qt.ImhPreferLowercase - Lower case letters are preferred (but not required).
- Qt.ImhNoPredictiveText - Do not use predictive text (i.e. dictionary lookup) while typing.
- Qt.ImhDate - The text editor functions as a date field.
- Qt.ImhTime - The text editor functions as a time field.

Flags that restrict input (exclusive flags) are:

- Qt.ImhDigitsOnly - Only digits are allowed.
- Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign.
- Qt.ImhUppercaseOnly - Only upper case letter input is allowed.
- Qt.ImhLowercaseOnly - Only lower case letter input is allowed.
- Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed.
- Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed.
- Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed.

Masks:

- Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used.

This property was introduced in QtQuick.Controls 2.2 (Qt 5.9).

### stepSize : double

This property holds the step size. The default value is `1.0`.

See also increase() and decrease().

### textFromValue : function

This property holds a callback function that is called whenever a double value needs to be converted to display text.

The default function can be overridden to display custom text for a given value. This applies to both editable and non-editable spinboxes; for example, when using the up and down buttons or a mouse wheel to increment and decrement the value, the new value is converted to display text using this function.

The callback function signature is `string function(value, decimals, locale)`. The function can have two or three arguments, where the first argument is the value to be converted, the second argument is the number of decimals, and the optional third argument is the locale that should be used for the conversion, if applicable.

The default implementation does the conversion using Number.toLocaleString():

     textFromValue: function(value, decimals, locale) {
         return Number(value).toLocaleString(locale, 'f', decimals);
     }

Note: When applying a custom `textFromValue` implementation for editable spinboxes, a matching valueFromText implementation must be provided to be able to convert the custom text back to a double value.

See also valueFromText, validator, and locale.

### to : int

This property holds the end value for the range. The default value is `2`.

See also from and value.

### up group

### up.hovered : bool

### up.implicitIndicatorHeight : real

### up.implicitIndicatorWidth : real

### up.indicator : Item

### up.pressed : bool

This grouped property holds the up indicator item and its associated properties.

See also increase().

### validator : Validator

This property holds the input text validator for editable spinboxes. By default, DoubleSpinBox uses DoubleValidator to accept input of double numbers.

     DoubleSpinBox {
         id: control
         validator: DoubleValidator {
             locale: control.locale.name
             bottom: Math.min(control.from, control.to)
             top: Math.max(control.from, control.to)
         }
     }

See also editable, textFromValue, valueFromText, locale, and Validating Input Text.

### value : double

This property holds the value in the range `from` - `to`. The default value is `0.0`.

### valueFromText : function

This property holds a callback function that is called whenever input text needs to be converted to a double value.

This function only needs to be overridden when textFromValue is overridden for an editable spinbox.

The callback function signature is `int function(text, locale)`. The function can have one or two arguments, where the first argument is the text to be converted, and the optional second argument is the locale that should be used for the conversion, if applicable.

The default implementation does the conversion using Number.fromLocaleString():

     valueFromText: function(text, locale) { return Number.fromLocaleString(locale, text); }

Note: When applying a custom textFromValue implementation for editable spinboxes, a matching `valueFromText` implementation must be provided to be able to convert the custom text back to a double value.

See also textFromValue, validator, and locale.

### wrap : bool `[since QtQuick.Controls 2.3 (Qt 5.10)]`

This property holds whether the spinbox wraps. The default value is `false`.

If wrap is `true`, stepping past to changes the value to from and vice versa.

This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

## Signal Documentation

### valueModified()

This signal is emitted when the spin box value has been interactively modified by the user by either touch, mouse, wheel, or keys. In the case of interaction via keyboard, the signal is only emitted when the text has been accepted; meaning when the enter or return keys are pressed, or the input field loses focus.

Note: The corresponding handler is `onValueModified`.

## Method Documentation

### void decrease()

Decreases the value by stepSize, or `1` if stepSize is not defined.

See also stepSize.

### void increase()

Increases the value by stepSize, or `1` if stepSize is not defined.

See also stepSize.