summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tableview.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-01 17:14:15 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-10 02:37:03 +0900
commitafd53be6f56c9622b4c3d55e6144a82cfa4c1eb1 (patch)
tree19eb8ddfeb44674d2547d86606750ff3630c81b5 /desktop-widgets/tableview.cpp
parent042799eb2a4e94d854b10a9db679e5b050cda38d (diff)
downloadsubsurface-afd53be6f56c9622b4c3d55e6144a82cfa4c1eb1.tar.gz
code cleanup: QFontMetrics::width() is deprecated
Qt5.11 introduced the suggested replacement QFontMetrics::horizontalAdvance(). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/tableview.cpp')
-rw-r--r--desktop-widgets/tableview.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/desktop-widgets/tableview.cpp b/desktop-widgets/tableview.cpp
index 13f7a9d03..19aaf602b 100644
--- a/desktop-widgets/tableview.cpp
+++ b/desktop-widgets/tableview.cpp
@@ -139,7 +139,12 @@ int TableView::defaultColumnWidth(int col)
{
int width;
QString text = ui.tableView->model()->headerData(col, Qt::Horizontal).toString();
- width = text.isEmpty() ? metrics.rm_col_width : defaultModelFontMetrics().width(text) + 4; // add small margin
+#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
+ int textSpace = defaultModelFontMetrics().width(text) + 4;
+#else // QT 5.11 or newer
+ int textSpace = defaultModelFontMetrics().horizontalAdvance(text) + 4;
+#endif
+ width = text.isEmpty() ? metrics.rm_col_width : textSpace + 4; // add small margin
#if defined(Q_OS_MAC)
width += 10; // Mac needs more margin
#endif