hiro/qt: QFontMetrics::width -> QFontMetrics::horizontalAdvance

QFontMetrics::width was deprecated in Qt 5.11 in favor of Qt
QFontMetrics::horizontalAdvance. Because QFontMetrics::horizontalAdvance
was introduced in Qt 5.11, it poses the most risk of breaking an
existing user of almost any of the deprecation changes, but Qt 5.11 is
fairly old by now (2018) and has been EOL for a while, so I still opted
to just move to the new function rather than use a version guard.
This commit is contained in:
John Chadwick 2025-09-01 03:32:30 -04:00 committed by Screwtapello
parent 58694a2935
commit fb09f52093
1 changed files with 1 additions and 1 deletions

View File

@ -11,7 +11,7 @@ auto pFont::size(const QFont& qtFont, const string& text) -> Size {
signed maxWidth = 0;
auto lines = text.split("\n");
for(auto& line : lines) {
maxWidth = max(maxWidth, metrics.width(QString::fromUtf8(line)));
maxWidth = max(maxWidth, metrics.horizontalAdvance(QString::fromUtf8(line)));
}
return {maxWidth, metrics.height() * (signed)lines.size()};
}