Stabilize tst_QSpinBox::sizeHint() by explicitly calling setLayout()

The test function places a QSpinBox in a QHBoxLayout, which has a
QWidget parent. The spin box is expected to be shown with the widget.
While the widget is the layout's parent, the layout is not explicitly
set. That makes the test function flaky in some cases.

This patch adds QWidget::setLayout() to explicitly set the layout on
the widget.

Pick-to: 6.5 6.4 6.2
Change-Id: I3a1cc77c302c5ba96d3628d035139f9718dda9e5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
This commit is contained in:
Axel Spoerl 2022-12-20 09:24:24 +01:00
parent dbcbadb7ac
commit 8e6ede7cd1

View File

@ -1154,6 +1154,7 @@ void tst_QSpinBox::sizeHint()
{
QWidget *widget = new QWidget;
QHBoxLayout *layout = new QHBoxLayout(widget);
widget->setLayout(layout);
sizeHint_SpinBox *spinBox = new sizeHint_SpinBox;
layout->addWidget(spinBox);
widget->show();