QWizardPage Class

The QWizardPage class is the base class for wizard pages. More...

Header: #include <QWizardPage>
qmake: QT += widgets
Since: Qt 4.3
Inherits: QWidget

This class was introduced in Qt 4.3.

Properties

Public Functions

void setSubTitle(const QString &subTitle)
void setTitle(const QString &title)
QString subTitle() const
QString title() const

Detailed Description

QWizard represents a wizard. Each page is a QWizardPage. When you create your own wizards, you can use QWizardPage directly, or you can subclass it for more control.

A page has the following attributes, which are rendered by QWizard: a title, a subTitle, and a set of pixmaps. See Elements of a Wizard Page for details. Once a page is added to the wizard (using QWizard::addPage() or QWizard::setPage()), wizard() returns a pointer to the associated QWizard object.

Page provides five virtual functions that can be reimplemented to provide custom behavior:

  • initializePage() is called to initialize the page's contents when the user clicks the wizard's Next button. If you want to derive the page's default from what the user entered on previous pages, this is the function to reimplement.
  • cleanupPage() is called to reset the page's contents when the user clicks the wizard's Back button.
  • validatePage() validates the page when the user clicks Next or Finish. It is often used to show an error message if the user has entered incomplete or invalid information.
  • nextId() returns the ID of the next page. It is useful when creating non-linear wizards, which allow different traversal paths based on the information provided by the user.
  • isComplete() is called to determine whether the Next and/or Finish button should be enabled or disabled. If you reimplement isComplete(), also make sure that completeChanged() is emitted whenever the complete state changes.

Normally, the Next button and the Finish button of a wizard are mutually exclusive. If isFinalPage() returns true, Finish is available; otherwise, Next is available. By default, isFinalPage() is true only when nextId() returns -1. If you want to show Next and Final simultaneously for a page (letting the user perform an "early finish"), call setFinalPage(true) on that page. For wizards that support early finishes, you might also want to set the HaveNextButtonOnLastPage and HaveFinishButtonOnEarlyPages options on the wizard.

In many wizards, the contents of a page may affect the default values of the fields of a later page. To make it easy to communicate between pages, QWizard supports a "field" mechanism that allows you to register a field (e.g., a QLineEdit) on a page and to access its value from any page. Fields are global to the entire wizard and make it easy for any single page to access information stored by another page, without having to put all the logic in QWizard or having the pages know explicitly about each other. Fields are registered using registerField() and can be accessed at any time using field() and setField().

See also QWizard, Class Wizard Example, and License Wizard Example.

Property Documentation

subTitle : QString

This property holds the subtitle of the page

The subtitle is shown by the QWizard, between the title and the actual page. Subtitles are optional. In ClassicStyle and ModernStyle, using subtitles is necessary to make the header appear. In MacStyle, the subtitle is shown as a text label just above the actual page.

The subtitle may be plain text or HTML, depending on the value of the QWizard::subTitleFormat property.

By default, this property contains an empty string.

Access functions:

QString subTitle() const
void setSubTitle(const QString &subTitle)

See also title, QWizard::IgnoreSubTitles, and Elements of a Wizard Page.

title : QString

This property holds the title of the page

The title is shown by the QWizard, above the actual page. All pages should have a title.

The title may be plain text or HTML, depending on the value of the QWizard::titleFormat property.

By default, this property contains an empty string.

Access functions:

QString title() const
void setTitle(const QString &title)

See also subTitle and Elements of a Wizard Page.