Fix compiler warning in gb.qt5 about deprecation of QFontMetrics::width()

QFontMetrics::width() is deprecated since Qt 5.11
This commit is contained in:
Laurent Carlier 2019-10-31 10:29:04 +01:00
parent 3f099c9b83
commit daf012a246
2 changed files with 8 additions and 0 deletions

View file

@ -124,7 +124,11 @@ static int get_text_width(QPainter *dp, QString &s)
for (i = 0; i < (int)text_sl.count(); i++)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
w = dp->fontMetrics().horizontalAdvance(text_sl[i]);
#else
w = dp->fontMetrics().width(text_sl[i]);
#endif
if (w > width) width = w;
text_w[i] = w;
}

View file

@ -932,7 +932,11 @@ static int get_text_width(QPainter *dp, QString &s)
for (i = 0; i < (int)text_sl.count(); i++)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
w = dp->fontMetrics().horizontalAdvance(text_sl[i]);
#else
w = dp->fontMetrics().width(text_sl[i]);
#endif
if (w > width) width = w;
text_w[i] = w;
}