From 777053cfff40570282e861527e0e52e22a359629 Mon Sep 17 00:00:00 2001 From: Qiang Li Date: Wed, 14 Apr 2021 11:15:46 +0800 Subject: Re-layout QProgressDialog when setting the cancel button Setting a cancel button on QProgressDialog more than once caused the layout to be invalid. The layout was only applied when the dialog resizes or the style changes, but not when a new cancel button is set. The solution is to update the layout() before showing the dialog when adopting new child widgets. Fixes: QTBUG-19983 Pick-to: 6.0 6.1 Change-Id: Id8fb1ac56e94a9bd97d4559a2e8d4835856fd7d0 Reviewed-by: Volker Hilsheimer --- src/widgets/dialogs/qprogressdialog.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/widgets/dialogs/qprogressdialog.cpp') 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(); } -- cgit v1.2.3