When I use
QRect bounds = QFontMetrics.boundingRect(0, 0, maxWidth, 0, Qt::TextWordWrap, string);
the resulting bounds rectangle is not always big enough to render the same string using the call
drawText(bounds, Qt::TextWordWrap, string);
because those two functions use different algorithms to calculate the font width metrics that affect the word break position.
In the first attached screen shot, the bounding rectangle of the string "Effets de bureau" is used to draw the text, which gets then cropped to "Effets de".
In the second screen shot, the bounding rectangle returned by QFontMetrics is enlarged by 2 pixels in width, and drawText() now renders the string
This bug depends on used font, font size, server DPI, and actual text, so no test case to reproduce.
|For Gerrit Dashboard: QTBUG-7768|
|376365,13||Fix inconsistencies between advanceWidth and bounding rects||dev||qt/qtbase||Status: MERGED||+2||0|