summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp24
2 files changed, 26 insertions, 0 deletions
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 32834291b8..448acfc7f9 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -485,6 +485,8 @@ void QProgressDialogPrivate::adoptChildWidget(QWidget *c)
c->setParent(q, { });
}
ensureSizeIsAtLeastSizeHint();
+ //The layout should be updated again to prevent layout errors when the new 'widget' is replaced
+ layout();
if (c)
c->show();
}
diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
index b847315abd..86963ce24a 100644
--- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
+++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
@@ -51,6 +51,7 @@ private Q_SLOTS:
void getSetCheck();
void task198202();
void QTBUG_31046();
+ void QTBUG_19983();
void settingCustomWidgets();
void i18n();
void setValueReentrancyGuard();
@@ -210,6 +211,29 @@ void tst_QProgressDialog::QTBUG_31046()
QCOMPARE(50, dlg.value());
}
+void tst_QProgressDialog::QTBUG_19983()
+{
+ QProgressDialog tempDlg;
+ tempDlg.setRange(0, 0);
+ tempDlg.setLabelText("This is a test.");
+
+ QPushButton *btnOne = new QPushButton("Cancel", &tempDlg);
+ tempDlg.setCancelButton(btnOne);
+ tempDlg.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&tempDlg));
+ const auto btnOneGeometry = btnOne->geometry();
+ QVERIFY(QPoint(0,0) != btnOneGeometry.topLeft());
+
+ tempDlg.cancel();
+ QVERIFY(!tempDlg.isVisible());
+
+ QPushButton *btnTwo = new QPushButton("Cancel", &tempDlg);
+ tempDlg.setCancelButton(btnTwo);
+ tempDlg.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&tempDlg));
+ QCOMPARE(btnOneGeometry, btnTwo->geometry());
+}
+
void tst_QProgressDialog::settingCustomWidgets()
{
QPointer<QLabel> l = new QLabel;