From 5ad1d0b83add4c7f494cd4bfe39f7f0ae371d9cf Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Tue, 20 Dec 2022 09:24:24 +0100 Subject: [PATCH] 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. Change-Id: I3a1cc77c302c5ba96d3628d035139f9718dda9e5 Reviewed-by: Paul Wicking (cherry picked from commit 8e6ede7cd131682161180bfab0cc46686674709b) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 08b2e17ce8c..eddc73d4dfe 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -1152,6 +1152,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();