Replace deprecated function call

QFontMetrics::width() has been deprecated. Using QFontMetrics::horizontalAdvance() is the proper way to go (introduce in Qt 5.11).
This commit is contained in:
Joel Bodenmann 2019-08-06 22:36:27 +02:00
parent 0b88843d76
commit 2b7232c9b3

View File

@ -157,7 +157,11 @@ QSize CElidingLabel::minimumSizeHint() const
return QLabel::minimumSizeHint();
}
const QFontMetrics &fm = fontMetrics();
QSize size(fm.width(d->Text.left(2) + ""), fm.height());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
QSize size(fm.horizontalAdvance(d->Text), QLabel::sizeHint().height());
#else
QSize size(fm.width(d->Text), QLabel::sizeHint().height());
#endif
return size;
}
@ -170,7 +174,11 @@ QSize CElidingLabel::sizeHint() const
return QLabel::sizeHint();
}
const QFontMetrics& fm = fontMetrics();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
QSize size(fm.horizontalAdvance(d->Text), QLabel::sizeHint().height());
#else
QSize size(fm.width(d->Text), QLabel::sizeHint().height());
#endif
return size;
}