Fix irrelevant error case in QSplitter test

The tst_QSplitter::replaceWidget() is testing that if you
replace a longer QLabel with a shorter one in a horizontal
splitter layout, then we *only* get a resize for the new,
shorter label (expanding it horizontally to match the
replaced widget, as documented).

But the test accidentally triggered the QTextDocument backend
for the QLabel by including HTML tags in its text. Due to
QTBUG-82954, it is possible that the QTextDocument height
includes the leading of the font in the last line, so if
the default font has a leading, the new label will be higher
than the QSplitter, and the splitter will expand its height,
causing resizes for the other labels as well.

Since this is not the case we are testing here, and it is
currently blocking the fix for QTBUG-80554, we simply make
the new label use the same plain text backend as the others.

Task-number: QTBUG-82954
Change-Id: I6bfa1f3648b0fc9758c57ab2fa95be2451995df3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2020-04-02 07:28:25 +02:00
parent a845e1db18
commit f66a8edc20

View File

@ -763,7 +763,7 @@ void tst_QSplitter::replaceWidget()
// the same size on the new widget. Because of QLabel's sizing
// constraints (they can expand but not shrink) the easiest is
// to set a shorter label.
QLabel *newWidget = new QLabel(QLatin1String("<b>NEW</b>"));
QLabel *newWidget = new QLabel(QLatin1String("NEW"));
EventCounterSpy ef(&sp);
ef.installEventFilter();