PyQt5 QSpinBox – Getting tight bounding rectangle of the font
In this article we will see how we can get the tight bounding rectangle of the spin box’s font i.e text. The bounding rectangle always covers at least the set of pixels the text would cover if drawn at (0, 0).
Note : Newline characters are processed as normal characters, not as line breaks.
In order to do this we use
tightBoundingRect method with the spin box’s QFontMetrics object.
Syntax : font_metrics.tightBoundingRect(text)
Argument : It takes string as argument
Return : It returns QRect object.
Below is the implementation
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course