PyQt5 QSpinBox - Getting height of 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 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. Syntax : font_metrics.height() 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 height of the font height = f_metrics.height() # setting text to the label label.setText("Height : " + str(height)) # 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 Font Info Object R rakshitarora Follow Improve Article Tags : Python Python-PyQt Python-gui Python PyQt-SpinBox Practice Tags : python Similar Reads PyQt5 QSpinBox - Getting MM Height In this article we will see how we can get the MM Height of the spin box. MM Height is basically the height of the paint device in millimeters. Due to platform limitations it may not be possible to use this function to determine the actual physical size of a spin box on the screen. In order to do th 2 min read PyQt5 QSpinBox - Getting Font Info Object In this article we will see how we can get the font info object of the spin box, in order to set the font use setFont method which takes QFont object as argument, using it with the spin box object will change the font of all the text. Font Info object is an object which tells about the properties of 2 min read 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 leading value of the font In this article we will see how we can get the leading value of the spin box's font. Leading value of the text means the distance between two baselines of lines of type. The word 'leading' originates from the strips of lead hand-typesetters used to use to space out lines of text evenly. The word lea 2 min read PyQt5 QSpinBox - Getting descent of the font 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 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 Like