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/other | |
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/other')
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 7976e0d626..b5d45adadb 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1695,7 +1695,7 @@ static QRect characterRect(const QTextEdit &edit, int offset) ++it; QFontMetrics fm(it.fragment().charFormat().font()); QChar ch = edit.document()->characterAt(offset); - int w = fm.width(ch); + int w = fm.horizontalAdvance(ch); int h = fm.height(); qreal x = line.cursorToX(relativeOffset); @@ -1766,9 +1766,9 @@ void tst_QAccessibility::textEditTest() QCOMPARE(endOffset, 31); QCOMPARE(textIface->characterCount(), 48); QFontMetrics fm(edit.document()->defaultFont()); - QCOMPARE(textIface->characterRect(0).size(), QSize(fm.width("h"), fm.height())); - QCOMPARE(textIface->characterRect(5).size(), QSize(fm.width(" "), fm.height())); - QCOMPARE(textIface->characterRect(6).size(), QSize(fm.width("w"), fm.height())); + QCOMPARE(textIface->characterRect(0).size(), QSize(fm.horizontalAdvance("h"), fm.height())); + QCOMPARE(textIface->characterRect(5).size(), QSize(fm.horizontalAdvance(" "), fm.height())); + QCOMPARE(textIface->characterRect(6).size(), QSize(fm.horizontalAdvance("w"), fm.height())); int offset = 10; QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("d")); |