PyQt5 QSpinBox - Checking if user can change value using keyboard or not Last Updated : 17 May, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article we will see how we can check if user can change the spin box value using key board or not, 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. We can stop keyboard input of spin box using setReadOnly method with its line edit object. In order to check this we use isReadOnly method with the line edit object Syntax : line_edit.isReadOnly() Argument : It takes no argument Return: It returns bool 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 5. Create a label to show result 6. Check if line edit is read only or not 7. Show check value on screen through label Below is the implementation Python3 1== # importing libraries from PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGui from PyQt5.QtGui import * from PyQt5.QtCore import * import sys class Window(QMainWindow): def __init__(self): super().__init__() # setting title self.setWindowTitle("Python ") # setting geometry self.setGeometry(100, 100, 600, 400) # calling method self.UiComponents() # showing all the widgets self.show() # method for widgets def UiComponents(self): # creating spin box self.spin = QSpinBox(self) # setting geometry to spin box self.spin.setGeometry(100, 100, 250, 40) # setting prefix to spin self.spin.setPrefix("Prefix ") # setting suffix to spin self.spin.setSuffix(" Suffix") # getting the line edit line = self.spin.lineEdit() # making the line edit part read only line.setReadOnly(True) # creating a label label = QLabel(self) # setting geometry to the label label.setGeometry(100, 200, 300, 30) # checking if line edit is read only check = line.isReadOnly() # setting text to label label.setText("Keyboard can't change value ? : " + str(check)) # create pyqt5 app App = QApplication(sys.argv) # create the instance of our Window window = Window() # start the app sys.exit(App.exec()) Output : Comment More infoAdvertise with us Next Article PyQt5 QSpinBox - Checking if the arrow buttons are removed or not R rakshitarora Follow Improve Article Tags : Python Python-PyQt Python-gui Python PyQt-SpinBox Python PyQt-SpinBox-stylesheet +1 More Practice Tags : python Similar Reads PyQt5 QSpinBox - Checking if signals are blocked or not In this article we will see how we can check if the signals are blocked or not of the spin box, blocking signals means the connected methods with the spin box will not receive the signals for example when we add action to it when its value changes that action will not work. Signals emitted while bei 2 min read PyQt5 QSpinBox - Checking if tablet tracking is activated or not In this article we will see how we can check if the spin box has tablet tracking enabled or not. By default tablet tracking is in off state. If tablet tracking is switched off, tablet move events only occur if the stylus is in contact with the tablet, or at least one stylus button is pressed, while 2 min read PyQt5 QSpinBox - Checking if the arrow buttons are removed or not In this article we will see how we can check if the spin box arrow buttons are removed or not, basically there are two buttons in the spin box one for incrementing the value and second for decrementing the value. In order to remove the buttons we use setButtonSymbols method. In order to check we wil 2 min read PyQt5 QSpinBox â Checking if it is visible using isVisible In this article we will see how we can check if the spin box visible with the help of isVisible method. We can hide the spin box using hide method or setHidden method. By default spin box is visible. Note : If we use this method inside the window class it will return false as the window is created a 2 min read PyQt5 QComboBox â Checking if mouse tracking is activated or not In this article we will see how we can check if the mouse tracking of the combo box is activated or not, combo box receive signal about the mouse when any button is pressed but after mouse tracking it will receive all the signals about the mouse even if any button is not pressed. By default this pro 2 min read PyQt5 QSpinBox - Checking if it is read only In this article we will see how we can check if the spin box is read only or not, read only means that user will not be able to change the value of it. It is similar to making a spin box disabled but when spin box is disabled its other properties are turned off as well but in read only no one can ed 2 min read Like