diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2017-08-02 11:39:01 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2017-12-08 15:06:32 +0000 |
commit | 4d88d79aa507777bce40740b21747f656efc074d (patch) | |
tree | 0b335cac61062eaf281b5a76514f8bd74bbcaaf2 /tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp | |
parent | cd56e843cc53938111879c21570eaf8225719743 (diff) |
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 <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp')
-rw-r--r-- | tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 06302f4cc1..9e705b4a00 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -167,7 +167,7 @@ void tst_QFontMetrics::elidedText() QFETCH(QFont, font); QFETCH(QString, text); QFontMetrics fm(font); - int w = fm.width(text); + int w = fm.horizontalAdvance(text); QString newtext = fm.elidedText(text,Qt::ElideRight,w+1, 0); QCOMPARE(text,newtext); // should not elide newtext = fm.elidedText(text,Qt::ElideRight,w-1, 0); @@ -202,7 +202,7 @@ void tst_QFontMetrics::bypassShaping() QVERIFY(textWidth != 0); int charsWidth = 0; for (int i = 0; i < text.size(); ++i) - charsWidth += fm.width(text[i]); + charsWidth += fm.horizontalAdvance(text[i]); // This assertion is needed in Qt WebKit's WebCore::Font::offsetForPositionForSimpleText QCOMPARE(textWidth, charsWidth); } @@ -226,7 +226,7 @@ template<class FontMetrics, typename PrimitiveType> void elidedMultiLength_helpe // Not even wide enough for "small" - should use ellipsis QChar ellipsisChar(0x2026); QString text1_el = QString::fromLatin1("s") + ellipsisChar; - PrimitiveType width_small = fm.width(text1_el); + PrimitiveType width_small = fm.horizontalAdvance(text1_el); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_small + 1), text1_el); } |