Skip to content

QDoubleSpinBox


QDoubleSpinBox is designed to handle double values. For integers, use QSpinBox instead. QDoubleSpinBox allows the user to choose a value by clicking the up and down buttons to increment or decrement the value displayed. The value can also be changed by typing in a value. The range of valid values and the number of decimal places shown is configurable.


Signals

  • valueChanged: Emitted when the value in the spin box changes.

Methods


Examples


spin_box = QtWidgets.QDoubleSpinBox()
spin_box.setMaximum(100)
spin_box.setMinimum(0)
spin_box.setSingleStep(0.1)
spin_box.setValue(50)
print(spin_box.value())
50.0
spin_box.setValue(200)
print(spin_box.value())
100.0


setMaximum(max)

Set the maximum value of the spin box. The default maximum value is 99.99.

Parameters:

Name Type Description Default
max float

The new maximum value.

required


setMinimum(min)

Set the minimum value of the spin box. The default minimum value is 0.0.

Parameters:

Name Type Description Default
min float

The new minimum value.

required


setPrefix(prefix)

Set the prefix of the spin box. The prefix is displayed before the value in the spin box and is not editable by the user.

Parameters:

Name Type Description Default
prefix str

The new prefix.

required


setRange(min, max)

Set the minimum and maximum values of the spin box. If the current value is outside the new range, the value is adjusted to the nearest limit.

Parameters:

Name Type Description Default
min float

The new minimum value.

required
max float

The new maximum value.

required


setSingleStep(val)

Set the value that the spin box will increment or decrement by when the up or down buttons are clicked. The default step value is 1.0. Setting a singleStep value of less than 0 does nothing.

Parameters:

Name Type Description Default
val float

The new step value.

required


setSuffix(suffix)

Set the suffix of the spin box. The suffix is displayed after the value in the spin box and is not editable by the user.

Parameters:

Name Type Description Default
suffix str

The new suffix.

required


setValue(val)

Set the value of the spin box. If the value is outside the range of the spin box, the value is adjusted to the nearest limit.

Parameters:

Name Type Description Default
val float

The new value.

required


value()

Returns the value of the spin box.

Returns:

Type Description
float

The value of the spin box.