[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: Question about QApplication.fontMetrics() in PyQt6
From:       Florian Bruhin <me () the-compiler ! org>
Date:       2021-01-13 7:43:54
Message-ID: 20210113074354.kj5lq54cfah6fo77 () aragog ! localdomain
[Download RAW message or body]


Hey,

On Tue, Jan 12, 2021 at 11:13:36PM +0800, RedHuli wrote:
> 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 :
> 
> font_size = QApplication.fontMetrics() # Calculate the size of the text
> 
> 
> AttributeError: type object 'QApplication' has no attribute 'fontMetrics'
> 
> I am reimplementing the sizeHint() method when subclassing
> QStyledItemDelegate.

Looks like it's marked as obsolete in Qt 6:
https://doc.qt.io/qt-6/qapplication-obsolete.html

Looks like this is the recommended replacement:
https://doc.qt.io/qt-6/qfontmetricsf.html#QFontMetricsF

Florian

-- 
            me@the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
             I love long mails! | https://email.is-not-s.ms/

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic