diff options
author | Axel Spoerl <Axel.Spoerl@qt.io> | 2022-02-03 17:05:50 +0100 |
---|---|---|
committer | Axel Spoerl <Axel.Spoerl@qt.io> | 2022-03-12 13:24:29 +0100 |
commit | 2140edaaab0bf61f354db521efca773568becc56 (patch) | |
tree | f37339eed9ee112b7e93fc60bf6a7ae49c9493f3 /src/widgets/dialogs/qwizard.cpp | |
parent | 297fdcaf30fc5e5a09d5b8a202297874dea01907 (diff) |
Add setCurrentId in QWizard
setCurrentId(int id) implemented incl. forward skip warning
respective test added in tst_qwizard
Fixes: QTBUG-99488
Change-Id: Ieaf31698baf1e8ec97484b4a221c8587385c9fb3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/dialogs/qwizard.cpp')
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 5acc7b880f..bf58fdac47 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -3142,6 +3142,42 @@ void QWizard::next() } /*! + Sets currentId to \a id, without visiting the pages between currentId and \a id. + + Returns without page change, if + \list + \li wizard holds no pages + \li current page is invalid + \li given page equals currentId() + \li given page is out of range + \endlist + + Note: If pages have been forward skipped and \a id is 0, page visiting history + will be deleted +*/ + +void QWizard::setCurrentId(int id) +{ + Q_D(QWizard); + + if (d->current == -1) + return; + + if (currentId() == id) + return; + + if (!validateCurrentPage()) + return; + + if (id < 0 || Q_UNLIKELY(!d->pageMap.contains(id))) { + qWarning("QWizard::setCurrentId: No such page: %d", id); + return; + } + + d->switchToPage(id, (id < currentId()) ? QWizardPrivate::Backward : QWizardPrivate::Forward); +} + +/*! Restarts the wizard at the start page. This function is called automatically when the wizard is shown. |