From: Elvis Angelaccio Date: Thu, 28 May 2020 20:40:57 +0000 (+0200) Subject: Port away from deprecated QFontMetrics::width() X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/b65576a131eb59eaab4d33af830bdb2d2f9fde9f?hp=b65576a131eb59eaab4d33af830bdb2d2f9fde9f Port away from deprecated QFontMetrics::width() While the documention says to port to QFontMetrics::horizontalAdvance(), what we actually need is not the horizontal advance, but the width of the text. So we need to port to QFontMetrics::boundingRect().width(). Quoting from https://kdepepo.wordpress.com/2019/08/05/about-deprecation-of-qfontmetricswidth/: "Since it was not clear from the confusingly named function QFontMetrics::width() that it actually returned the horizontal advance, instead of the bounding width, this method is now obsolete. You must port to either QFontMetrics::horizontalAdvance() or QFontMetrics::boundingRect().width(). Please make sure you are aware of the difference, and do not port blindly. I am pretty sure that in most cases QFontMetrics::boundingRect() is what you want, unless you are writing custom text shaping/layouting code. Using the wrong function can cause clipped text or text that suddenly wraps to the next line despite calculating the width that it needs." ---