Using the Spin Box widget
The Spin Box
widget is used for displaying integer values, floating-point values, and text. It applies a constraint on the user: the user cannot enter any random data, but can select only from the available options displayed through Spin Box
. A Spin Box
widget displays an initial value by default that can be increased or decreased by selecting the up/down button or up/down arrow key on the keyboard. You can choose a value that is displayed by either clicking on it or typing it in manually.
Getting ready
A Spin Box
widget can be created using two classes, QSpinBox
and QDoubleSpinBox
, where QSpinBox
displays only integer values, and the QDoubleSpinBox
 class displays floating-point values. Methods provided by QSpinBox
are shown in the following list:
value()
: This method returns the current integer value selected from the spin box.text()
: This method returns the text displayed by the spin box.setPrefix()
: This method assigns the prefix text that is prepended to the value...