PyQt5 QSpinBox - Adding Prefix Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In this article we will see how we can add prefix to the spin box, prefix is basically the text which is inserted before the value of spin box, prefix remain constant for each value of spin box i.e it is not editable. In order to add prefix we will use spin_box.setPrefix method. Syntax : spin_box.setPrefix(text) Argument : It takes string as argument Return : None Below is the implementation Python3 # 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, 150, 40) # adding prefix in combo box self.spin.setPrefix("Value of x : ") # 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 - Accessing Prefix R rakshitarora Follow Improve Article Tags : Python Python-PyQt Python-gui Python PyQt-SpinBox Practice Tags : python Similar Reads PyQt5 QSpinBox - Accessing Prefix In this article we will see how we can access the prefix of the spin box, prefix is basically the text which is inserted before the value of spin box, prefix remain constant for each value of spin box i.e it is not editable. By default no prefix is set to the spin box we use setPrefix method to set 2 min read PyQt5 QSpinBox - Adding border In this article we will see how we can add border to the spin box, by default spin box has a black color border although we can change it below is how customized border looks like. In order to do this we have to change the style sheet code associated with the spin box, below is the stylesheet code Q 2 min read PyQt5 QDoubleSpinBox â Getting Prefix In this article we will see how we can get prefix of the QDoubleSpinBox. A prefix is an affix which is placed before the stem of a word. Adding it to the beginning of one word changes it into another word. For example, when the prefix un- is added to the word happy, it creates the word unhappy. By d 2 min read PyQt5 QSpinBox - Adding Description In this article we will see how we can set description to the spin box, description is the detailed information about the combo box which tells about the functionality use cases and other main information to understand the working of the spin box. Description is used by the programmer for better und 2 min read PyQt5 QSpinBox â Accessing caption In this article we will see how we can access the caption of the spin box, caption is basically the heading of the spin box but it is not visible caption is for only back end purposes. Caption of spin box is similar to the caption of the main window. In order to do so we use windowTitle method. Synt 2 min read PyQt5 QSpinBox - Ensuring Polished In this article we will see how we can ensure that the spin box is polished. Polishing of spin box is done by using QStyle or by using style sheet. Polishing is done at the end when all the editing is done, although developer can ensure that polishing is done by using ensurePolished method. In order 2 min read Like