PyQt5 QSpinBox - Getting descent of the font Last Updated : 26 May, 2020 Comments Improve Suggest changes Like Article Like Report In this article we will see how we can get the descent of the spin box's font i.e text. The descent is the distance from the base line to the lowest point characters extend to. In practice, some font designers break this rule, e.g. to accommodate an unusual character in an exotic language, so it is possible (though rare) that this value will be too small. In order to do this we use descent method with the spin box's QFontMetrics object. Syntax : font_metrics.descent() Argument : It takes no argument Return : It returns integer 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 range to the spin box self.spin.setRange(0, 999999) # setting prefix to spin self.spin.setPrefix("PREFIX ") # setting suffix to spin self.spin.setSuffix(" SUFFIX") # creating a label label = QLabel(self) # making label multi line label.setWordWrap(True) # setting geometry to the label label.setGeometry(100, 200, 300, 60) # getting font metrics f_metrics = self.spin.fontMetrics() # getting descent value descent = f_metrics.descent() # setting text to the label label.setText("Descent : " + str(descent)) # 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 - Getting the line width of the font R rakshitarora Follow Improve Article Tags : Python Python-PyQt Python-gui Python PyQt-SpinBox Practice Tags : python Similar Reads PyQt5 QSpinBox - Getting ascent of the font In this article we will see how we can get the ascent of the spin box's font i.e text. The ascent of a font is the distance from the baseline to the highest position characters extend to. In practice, some font designers break this rule, e.g. when they put more than one accent on top of a character, 2 min read PyQt5 QSpinBox - Getting the size of the font In this article we will see how we can get size of the spin box's font i.e text. In order to get the size object we have to get the QFontMetrics object of the size box to get the size. The size will be in pixels. In order to do this we use size method with the spin box's QFontMetrics object. Syntax 2 min read PyQt5 QSpinBox - Getting height of font In this article we will see how we can get the height of the spin box's font i.e its text. Height is the vertical length of the text. Height of font is always equal to ascent +descent +1 (the 1 is for the base line). In order to do this we use height method with the spin box's QFontMetrics object. S 2 min read PyQt5 QSpinBox - Getting the line width of the font In this article we will see how we can get the line width of the spin box font. Line width is the width of the underline and strikeout lines, adjusted for the point size of the font. In order to do this we use lineWidth method with the spin box's QFontMetrics object. Syntax : font_metrics.lineWidth( 2 min read PyQt5 QSpinBox - Getting the frame geometry In this article we will see how we can get the frame geometry of the spin box. Frame geometry is the spin box geometry relative to its parent including any window frame. By default, frame geometry of the spin box contains a value that depends on the user's platform and screen geometry. In order to d 2 min read PyQt5 QSpinBox - Getting the minimum left bearing of the font In this article we will see how we can get the minimum left bearing of the spin box's font. Minimum left bearing value is the smallest leftBearing value of all characters in the font. The left bearing is the right-ward distance of the left-most pixel of the character from the logical origin of the c 2 min read Like