From afd53be6f56c9622b4c3d55e6144a82cfa4c1eb1 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Jan 2020 17:14:15 -0800 Subject: code cleanup: QFontMetrics::width() is deprecated Qt5.11 introduced the suggested replacement QFontMetrics::horizontalAdvance(). Signed-off-by: Dirk Hohndel --- desktop-widgets/divelistview.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'desktop-widgets/divelistview.cpp') diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index dd74bd46b..a34d78e5c 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -90,11 +90,17 @@ void DiveListView::resetModel() void DiveListView::calculateInitialColumnWidth(int col) { const QFontMetrics metrics(defaultModelFont()); + QString header_txt = MultiFilterSortModel::instance()->headerData(col, Qt::Horizontal, Qt::DisplayRole).toString(); + +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) int em = metrics.width('m'); int zw = metrics.width('0'); - - QString header_txt = MultiFilterSortModel::instance()->headerData(col, Qt::Horizontal, Qt::DisplayRole).toString(); int width = metrics.width(header_txt); +#else // QT 5.11 or newer + int em = metrics.horizontalAdvance('m'); + int zw = metrics.horizontalAdvance('0'); + int width = metrics.horizontalAdvance(header_txt); +#endif int sw = 0; switch (col) { case DiveTripModelBase::NR: -- cgit v1.2.3-70-g09d2