From 8a6f6851a49bc83a56756a8013e77c3d2d19d307 Mon Sep 17 00:00:00 2001 From: Noah Davis Date: Sun, 29 Dec 2019 03:53:46 -0500 Subject: [PATCH] Fix QFontMetrics::width() deprecation warning by switching to boundingRect().width() Summary: According to an article by @cfeck [1], QFontMetrics::width() gave the horizontal advance, which doesn't necessarily include every pixel that the text might use. He suggested that boundingRect().width() might be what most people actually want. - [1] https://kdepepo.wordpress.com/2019/08/05/about-deprecation-of-qfontmetricswidth/ Reviewers: #breeze, #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: hpereiradacosta, cfeck, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D26270 --- kstyle/breezestyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index 798aac37..712f7454 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -2836,7 +2836,7 @@ namespace Breeze if( !menuItemOption->text.isEmpty() ) { size.setHeight( qMax( size.height(), textHeight ) ); - size.setWidth( qMax( size.width(), menuItemOption->fontMetrics.width( menuItemOption->text ) ) ); + size.setWidth( qMax( size.width(), menuItemOption->fontMetrics.boundingRect( menuItemOption->text ).width() ) ); } return sizeFromContents( CT_ToolButton, &toolButtonOption, size, widget );