From: Philipp Spitzer Date: Wed, 14 Jul 2021 19:27:16 +0000 (+0200) Subject: Replace QFontMetrics::width() with QFontMetrics::horizontalAdvance() to avoid a depre... X-Git-Tag: 0.7.0~24 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/ce60f4216f20f3f3392e9e83e9c09e1e03e4308b Replace QFontMetrics::width() with QFontMetrics::horizontalAdvance() to avoid a deprecation warning. --- diff --git a/src/gui/daynavigatorwidget.cpp b/src/gui/daynavigatorwidget.cpp index 0aa3a84..0fdfe97 100644 --- a/src/gui/daynavigatorwidget.cpp +++ b/src/gui/daynavigatorwidget.cpp @@ -121,7 +121,12 @@ void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent) { #ifdef MAEMO qreal factor = 0.8; #else - qreal factor = (qreal) 2 * q.width() / painter.fontMetrics().width(selectedDateStr); +#if QT_VERSION >= 0x050b00 // QT 5.11 + auto dateStrWidth = painter.fontMetrics().horizontalAdvance(selectedDateStr); +#else + auto dateStrWidth = painter.fontMetrics().width(selectedDateStr); +#endif + qreal factor = (qreal) 2 * q.width() / dateStrWidth; #endif if (factor < 1) f.setPointSizeF(f.pointSizeF() * factor); painter.setFont(f);