From 4d88d79aa507777bce40740b21747f656efc074d Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 2 Aug 2017 11:39:01 +0200 Subject: Update usage of QFontMetrics::width() to new API QFontMetrics(F)::width() has been deprecated and is replaced by horizontalAdvance(). This updates all usage of it in tests and documentation. It is worth noting that many or most of the usages of QFontMetrics::width() probably intended to use boundingRect().width(), but since it currently works, I have not looked into that, just replaced the function name mechanically. Change-Id: Iec382e5bad0b50f37a6cfff841bfb46ed4d4555f Reviewed-by: Lars Knoll --- src/widgets/dialogs/qfiledialog.cpp | 8 ++++---- src/widgets/dialogs/qmessagebox.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/widgets/dialogs') diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index e375a957de..4cda5f34ad 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -2950,10 +2950,10 @@ void QFileDialogPrivate::createWidgets() qFileDialogUi->treeView->setModel(model); QHeaderView *treeHeader = qFileDialogUi->treeView->header(); QFontMetrics fm(q->font()); - treeHeader->resizeSection(0, fm.width(QLatin1String("wwwwwwwwwwwwwwwwwwwwwwwwww"))); - treeHeader->resizeSection(1, fm.width(QLatin1String("128.88 GB"))); - treeHeader->resizeSection(2, fm.width(QLatin1String("mp3Folder"))); - treeHeader->resizeSection(3, fm.width(QLatin1String("10/29/81 02:02PM"))); + treeHeader->resizeSection(0, fm.horizontalAdvance(QLatin1String("wwwwwwwwwwwwwwwwwwwwwwwwww"))); + treeHeader->resizeSection(1, fm.horizontalAdvance(QLatin1String("128.88 GB"))); + treeHeader->resizeSection(2, fm.horizontalAdvance(QLatin1String("mp3Folder"))); + treeHeader->resizeSection(3, fm.horizontalAdvance(QLatin1String("10/29/81 02:02PM"))); treeHeader->setContextMenuPolicy(Qt::ActionsContextMenu); QActionGroup *showActionGroup = new QActionGroup(q); diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 190ce93439..cb8ac1ccbf 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -415,7 +415,7 @@ void QMessageBoxPrivate::updateSize() } QFontMetrics fm(QApplication::font("QMdiSubWindowTitleBar")); - int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit); + int windowTitleWidth = qMin(fm.horizontalAdvance(q->windowTitle()) + 50, hardLimit); if (windowTitleWidth > width) width = windowTitleWidth; -- cgit v1.2.3