From 465b4124e626448006eed13bea1359c14960fc67 Mon Sep 17 00:00:00 2001 From: LoudSnorer Date: Sun, 19 Feb 2023 13:30:36 -0500 Subject: [PATCH] fix fontmeterics for QT < 11 --- oscar/Graphs/gGraphView.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/oscar/Graphs/gGraphView.cpp b/oscar/Graphs/gGraphView.cpp index 533ed8bf..947858fe 100644 --- a/oscar/Graphs/gGraphView.cpp +++ b/oscar/Graphs/gGraphView.cpp @@ -947,7 +947,11 @@ void gGraphView::DrawTextQue(QPainter &painter) if (q.angle == 0) { painter.drawText(q.x, q.y, q.text); } else { - w = painter.fontMetrics().horizontalAdvance(q.text); + #if (QT_VERSION >= QT_VERSION_CHECK(5,11,0)) + w = painter.fontMetrics().horizontalAdvance(q.text); + #else + w = painter.fontMetrics().width(q.text); + #endif h = painter.fontMetrics().xHeight() + 2; painter.translate(q.x, q.y); @@ -972,7 +976,11 @@ void gGraphView::DrawTextQue(QPainter &painter) if (q.angle == 0) { painter.drawText(q.rect, q.flags, q.text); } else { - w = painter.fontMetrics().horizontalAdvance(q.text); + #if (QT_VERSION >= QT_VERSION_CHECK(5,11,0)) + w = painter.fontMetrics().horizontalAdvance(q.text); + #else + w = painter.fontMetrics().width(q.text); + #endif h = painter.fontMetrics().xHeight() + 2; painter.translate(q.rect.x(), q.rect.y()); @@ -1013,7 +1021,11 @@ void gGraphView::DrawTextQueCached(QPainter &painter) if (!QPixmapCache::find(hstr, &pm)) { QFontMetrics fm(*q.font); - w = fm.horizontalAdvance(q.text); + #if (QT_VERSION >= QT_VERSION_CHECK(5,11,0)) + w = painter.fontMetrics().horizontalAdvance(q.text); + #else + w = painter.fontMetrics().width(q.text); + #endif h = fm.height()+buf; pm = QPixmap(w, h);