From 955d0df8736577eea0061e61a924104e34d3915d Mon Sep 17 00:00:00 2001 From: Christian Loose Date: Mon, 23 Sep 2013 20:40:52 +0200 Subject: Add option NoCancelButtonOnLastPage to QWizard Add support to hide the cancel button on the last page of a wizard. This is useful for wizards where the last page is used as a summary page that should not be cancelled. [ChangeLog][QtWidgets][QWizard] Added NoCancelButtonOnLastPage option. Task-number: QTBUG-7484 Change-Id: I282bda55a8dec9cde6439a9285d79e0a5c6df96a Reviewed-by: Marc Mutz --- tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index a711bc28e3..25a82050e3 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -90,6 +90,7 @@ private slots: void setOption_HaveNextButtonOnLastPage(); void setOption_HaveFinishButtonOnEarlyPages(); void setOption_NoCancelButton(); + void setOption_NoCancelButtonOnLastPage(); void setOption_CancelButtonOnLeft(); void setOption_HaveHelpButton(); void setOption_HelpButtonOnRight(); @@ -1423,6 +1424,50 @@ void tst_QWizard::setOption_NoCancelButton() } } +void tst_QWizard::setOption_NoCancelButtonOnLastPage() +{ + for (int i = 0; i < 2; ++i) { + QWizard wizard; + wizard.setOption(QWizard::NoCancelButton, false); + wizard.setOption(QWizard::NoCancelButtonOnLastPage, true); + wizard.addPage(new QWizardPage); + wizard.addPage(new QWizardPage); + wizard.page(1)->setFinalPage(true); // changes nothing (final != last in general) + wizard.addPage(new QWizardPage); + + wizard.setStartId(1); + wizard.show(); + qApp->processEvents(); + + QVERIFY(wizard.button(QWizard::CancelButton)->isVisible()); + + wizard.next(); + qApp->processEvents(); + QVERIFY(!wizard.button(QWizard::CancelButton)->isVisible()); + + wizard.next(); + qApp->processEvents(); + QVERIFY(!wizard.button(QWizard::CancelButton)->isVisible()); + + wizard.back(); + qApp->processEvents(); + QVERIFY(wizard.button(QWizard::CancelButton)->isVisible()); + + wizard.next(); + qApp->processEvents(); + QVERIFY(!wizard.button(QWizard::CancelButton)->isVisible()); + + wizard.setOption(QWizard::NoCancelButtonOnLastPage, false); + QVERIFY(wizard.button(QWizard::CancelButton)->isVisible()); + + wizard.setOption(QWizard::NoCancelButtonOnLastPage, true); + QVERIFY(!wizard.button(QWizard::CancelButton)->isVisible()); + + wizard.addPage(new QWizardPage); + QVERIFY(!wizard.button(QWizard::CancelButton)->isVisible()); // this is maybe wrong + } +} + void tst_QWizard::setOption_CancelButtonOnLeft() { for (int i = 0; i < 2; ++i) { -- cgit v1.2.3