Home

QtWizardPage Class Reference

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

    #include <QtWizardPage>

Inherits QWidget.

Properties

Public Functions

Signals

Protected Functions

Additional Inherited Members


Detailed Description

The QtWizardPage class is the base class for wizard pages.

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

A page has the following attributes, which are rendered by QtWizard: 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 QtWizard::addPage() or QtWizard::setPage()), wizard() returns a pointer to the associated QtWizard object.

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

Normally, the Next button and the Finish button of a wizard are mutually exclusive. If isFinal() returns true, Finish is available; otherwise, Next is available. By default, isFinal() 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 setFinal(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, QtWizard 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 QtWizard 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 QtWizard, 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 QtWizard, 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 QtWizard::subTitleFormat property.

Access functions:

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

title : QString

This property holds the title of the page.

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

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

Access functions:

See also subTitle and Elements of a Wizard Page.


Member Function Documentation

QtWizardPage::QtWizardPage ( QWidget * parent = 0 )

Constructs a wizard page with the given parent.

When the page is inserted into a wizard using QtWizard::addPage() or QtWizard::setPage(), the parent is automatically set to be the wizard.

See also wizard().

void QtWizardPage::cleanupPage ()   [virtual]

This virtual function is called by QtWizard::cleanupPage() when the user clicks Back (unless the QtWizard::IndependentPages option is set).

The default implementation resets the page's fields to their original values (the values they had before initializePage() was called).

See also QtWizard::cleanupPage(), initializePage(), and QtWizard::IndependentPages.

void QtWizardPage::completeChanged ()   [signal]

This signal is emitted whenever the complete state of the page (i.e., the value of isComplete()) changes.

If you reimplement isComplete(), make sure to emit completeChanged() whenever the value of isComplete() changes, to ensure that QtWizard updates the enabled or disabled state of its buttons.

See also isComplete().

QVariant QtWizardPage::field ( const QString & name ) const   [protected]

Returns the value of the field called name.

This function can be used to access fields on any page of the wizard. It is equivalent to calling wizard()->field(name).

Example:

    void OutputFilesPage::initializePage()
    {
        QString className = field("className").toString();
        headerLineEdit->setText(className.toLower() + ".h");
        implementationLineEdit->setText(className.toLower() + ".cpp");
        outputDirLineEdit->setText(QDir::convertSeparators(QDir::tempPath()));
    }

See also QtWizard::field(), setField(), and registerField().

void QtWizardPage::initializePage ()   [virtual]

This virtual function is called by QtWizard::initializePage() to prepare the page just before it is shown. (However, if the QtWizard::IndependentPages option is set, this function is only called the first time the page is shown.)

By reimplementing this function, you can ensure that the page's fields are properly initialized based on fields from previous pages. For example:

    void OutputFilesPage::initializePage()
    {
        QString className = field("className").toString();
        headerLineEdit->setText(className.toLower() + ".h");
        implementationLineEdit->setText(className.toLower() + ".cpp");
        outputDirLineEdit->setText(QDir::convertSeparators(QDir::tempPath()));
    }

The default implementation does nothing.

See also QtWizard::initializePage(), cleanupPage(), and QtWizard::IndependentPages.

bool QtWizardPage::isComplete () const   [virtual]

This virtual function is called by QtWizard to determine whether the Next or Finish button should be enabled or disabled.

The default implementation returns true if all mandatory fields are filled; otherwise, it returns false.

If you reimplement this function, make sure to emit completeChanged() whenever the value of isComplete() changes, to ensure that QtWizard updates the enabled or disabled state of its buttons.

See also completeChanged() and isFinal().

bool QtWizardPage::isFinal () const

This function is called by QtWizard to determine whether the Finish button should be shown for this page or not.

By default, it returns true if there is no next page (i.e., nextId() returns -1); otherwise, it returns false.

By explicitly calling setFinal(true), you can let the user perform an "early finish".

See also isComplete() and QtWizard::HaveFinishButtonOnEarlyPages.

int QtWizardPage::nextId () const   [virtual]

This virtual function is called by QtWizard::nextId() to find out which page to show when the user clicks the Next button.

By default, this function returns the page with the following ID in the QtWizard, or -1 if there is no such page.

By reimplementing this function, you can specify a dynamic page order. For example:

    int IntroPage::nextId() const
    {
        if (evaluateRadioButton->isChecked()) {
            return LicenseWizard::Page_Evaluate;
        } else {
            return LicenseWizard::Page_Register;
        }
    }

See also QtWizard::nextId().

QPixmap QtWizardPage::pixmap ( QtWizard::WizardPixmap which ) const

Returns the pixmap set for role which.

Pixmaps can also be set for the entire wizard using QtWizard::setPixmap(), in which case they apply for all pages that don't specify a pixmap.

See also setPixmap(), QtWizard::pixmap(), and Elements of a Wizard Page.

void QtWizardPage::registerField ( const QString & name, QWidget * widget, const char * property = 0, const char * changedSignal = 0 )   [protected]

Creates a field called name associated with the given property of the given widget. From then on, that property becomes accessible using field() and setField().

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 QtWizard or having the pages know explicitly about each other.

If name ends with an asterisk (*), the field is a mandatory field. When a page has mandatory fields, the Next and/or Finish buttons are enabled only when all mandatory fields are filled. This requires a changedSignal to be specified, to tell QtWizard to recheck the value stored by the mandatory field.

QtWizard knows the most common Qt widgets. For these (or their subclasses), you don't need to specify a property or a changedSignal. The table below lists these widgets:

WidgetPropertyChange Notification Signal
QAbstractButtonbool checkedtoggled()
QAbstractSliderint valuevalueChanged()
QComboBoxint currentIndexcurrentIndexChanged()
QDateTimeEditQDateTime dateTimedateTimeChanged()
QLineEditQString texttextChanged()
QListWidgetint currentRowcurrentRowChanged()
QSpinBoxint valuevalueChanged()

You can use QtWizard::setDefaultProperty() to add entries to this table or to override existing entries.

To consider a field "filled", QtWizard simply checks that their current value doesn't equal their original value (the value they had before initializePage() was called). For QLineEdit, it also checks that hasAcceptableInput() returns true, to honor any validator or mask.

QtWizard's mandatory field mechanism is provided for convenience. It can be bypassed by reimplementing QtWizardPage::isComplete().

See also field(), setField(), and QtWizard::setDefaultProperty().

void QtWizardPage::setField ( const QString & name, const QVariant & value )   [protected]

Sets the value of the field called name to value.

This function can be used to set fields on any page of the wizard. It is equivalent to calling wizard()->setField(name, value).

See also QtWizard::setField(), field(), and registerField().

void QtWizardPage::setFinal ( bool final )

Explicitly sets this page to be final if final is true.

After calling setFinal(true), isFinal() returns true and the Finish button is visible (and enabled if isComplete() returns true).

After calling setFinal(false), isFinal() returns true if nextId() returns -1; otherwise, it returns false.

See also isFinal(), isComplete(), and QtWizard::HaveFinishButtonOnEarlyPages.

void QtWizardPage::setPixmap ( QtWizard::WizardPixmap which, const QPixmap & pixmap )

Sets the pixmap for role which to pixmap.

The pixmaps are used by QtWizard when displaying a page. Which pixmaps are actually used depend on the wizard style.

Pixmaps can also be set for the entire wizard using QtWizard::setPixmap(), in which case they apply for all pages that don't specify a pixmap.

See also pixmap(), QtWizard::setPixmap(), and Elements of a Wizard Page.

bool QtWizardPage::validatePage ()   [virtual]

This virtual function is called by QtWizard::validateCurrentPage() when the user clicks Next or Finish to perform some last-minute validation. If it returns true, the next page is shown (or the wizard finishes); otherwise, the current page stays up.

The default implementation returns true.

When possible, it is usually better style to disable the Next or Finish button (by specifying mandatory fields or reimplementing isComplete()) than to reimplement validatePage().

See also QtWizard::validateCurrentPage() and isComplete().

QtWizard * QtWizardPage::wizard () const   [protected]

Returns the wizard associated with this page, or 0 if this page hasn't been inserted into a QtWizard yet.

See also QtWizard::addPage() and QtWizard::setPage().


Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions