<div dir="ltr"><div dir="ltr">This is a simple question I have about using QApplication.fontMetrics() in PyQt6. When I used it before in PyQt5, I never received an error message. However, when I want to get the font metrics I now get the error :<div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">font_size = QApplication.fontMetrics() # Calculate the size of the text</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">AttributeError: type object 'QApplication' has no attribute 'fontMetrics'</span></p></div><div><br></div><div>I am reimplementing the sizeHint() method when subclassing QStyledItemDelegate. </div><div><br></div><div>Thanks!</div></div></div>