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 <volker.hilsheimer@qt.io>
This commit is contained in:
parent
82f8519b82
commit
777053cfff
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user