PyQt5 QSpinBox – Stopping key board input
In this article we will see how we can make a spin box which can’t take input from the keyboard, when we create a spin box there are basically two ways to change the value of the spin box one is by using arrow buttons or other way is using key board. Stopping key board input of spin box means user will not be able to enter a value in spin box using keyboard although user can make increment or decrement using arrow buttons.
In order to stop key board input we use setReadOnly method with the line edit object Syntax : line_edit.setReadOnly(True) Argument : It takes bool as argument Action performed : It will make the line edit object read only
In order to do this we have to do the following : 1. Create a main window 2. Create a spin box 3. Get the line edit object from the spin box 4. Make the line edit part read only Below is the implementation