PyQt Basic Widgets PyQt QSpinBox Widget - PyQt

What is PyQt QSpinBox Widget?

A QSpinBox item presents the person with a textbox which presentations an integer with up/down button on its right. The value in the textbox increases/decreases if the up/down button is pressed.

Through default, the integer variety within the box starts with 0, goes upto 99 and changes by step 1. Use QDoubleSpinBox for drift values.

Important techniques of QSpinBox class are listed inside the following table –

S.No.

Methods & Description

1

setMinimum()

Sets the lower bound of counter

2

setMaximum()

Sets the upper bound of counter

3

setRange()

Sets the minimum, maximum and step value

4

setValue()

Sets the value of spin box programmatically

5

Value()

Returns the current value

6

singleStep()

Sets the step value of counter

QSpinBox item emits valueChanged() signal every time while up/own button is pressed. The related slot function can retrieve current value of the widget through value() technique.

Following example has a label (l1) and spinbox (sp) put in vertical format of a top window. The valueChanged() signal is attached to valuechange() technique.

The valueChange() function displays the current value as caption of the label.

The complete code is as follows –

The above code produces the following output –

PyQt - QSpinBox Widget

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PyQt Topics