Replace QFontMetrics::width() with QFontMetrics::horizontalAdvance() to avoid a depre...
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 14 Jul 2021 19:27:16 +0000 (21:27 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 14 Jul 2021 19:28:46 +0000 (21:28 +0200)
src/gui/daynavigatorwidget.cpp

index 0aa3a8401d945cd4a997469af8eb3fc1fc92ae8d..0fdfe97ff74f1efe5ec37e98750918dee6c3ac3c 100644 (file)
@@ -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);