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/doc/snippets/javastyle.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets/doc/snippets/javastyle.cpp') diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp index bddc303f71..8657d5ed29 100644 --- a/src/widgets/doc/snippets/javastyle.cpp +++ b/src/widgets/doc/snippets/javastyle.cpp @@ -214,7 +214,7 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option, painter->translate(box->rect.width(), -box->rect.height()); } - int textWidth = box->fontMetrics.width(box->text) + 20; + int textWidth = box->fontMetrics.horizontalAdvance(box->text) + 20; QPolygon innerLine; innerLine << (box->rect.topLeft() + QPoint(0, 1)) << @@ -1016,7 +1016,7 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option, int h = pixmap.height(); if (!button->text.isEmpty()) - w += button->fontMetrics.width(button->text) + 2; + w += button->fontMetrics.horizontalAdvance(button->text) + 2; point = QPoint(ir.x() + ir.width() / 2 - w / 2, ir.y() + ir.height() / 2 - h / 2); @@ -2453,7 +2453,7 @@ QRect JavaStyle::subElementRect(SubElement element, rect.moveTopLeft(box->rect.topLeft() + QPoint(0, 2)); rect.setHeight(box->rect.height() - 4); - rect.setWidth(box->fontMetrics.width(box->text) + 15); + rect.setWidth(box->fontMetrics.horizontalAdvance(box->text) + 15); break; } case SE_ProgressBarLabel: @@ -2467,7 +2467,7 @@ QRect JavaStyle::subElementRect(SubElement element, qstyleoption_cast(option); rect = btn->fontMetrics.boundingRect(btn->text); - rect = QRect(0, 0, btn->fontMetrics.width(btn->text), + rect = QRect(0, 0, btn->fontMetrics.horizontalAdvance(btn->text), rect.height()); if (!btn->icon.isNull()) { -- cgit v1.2.3