com.trolltech.qt.gui
Class QWizard

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.core.QObject
                  extended by com.trolltech.qt.gui.QWidget
                      extended by com.trolltech.qt.gui.QDialog
                          extended by com.trolltech.qt.gui.QWizard
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QWizard
extends QDialog

The QWizard class provides a framework for wizards. A wizard (also called an assistant on Mac OS X) is a special type of input dialog that consists of a sequence of pages. A wizard's purpose is to guide the user through a process step by step. Wizards are useful for complex or infrequent tasks that users may find difficult to learn.

QWizard inherits QDialog and represents a wizard. Each page is a QWizardPage (a QWidget subclass). To create your own wizards, you can use these classes directly, or you can subclass them for more control.

Topics:

A Trivial Example

The following example illustrates how to create wizard pages and add them to a wizard. For more advanced examples, see
Class Wizard and License Wizard.

The following code example is written in c++.
QWizardPage *createIntroPage()
{
    QWizardPage *page = new QWizardPage;
    page->setTitle("Introduction");

    QLabel *label = new QLabel("This wizard will help you register your copy "
                               "of Super Product Two.");
    label->setWordWrap(true);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(label);
    page->setLayout(layout);

    return page;
}



QWizardPage *createRegistrationPage()

{
...
}
 
QWizardPage *createConclusionPage() { ... }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QString translatorFileName = QLatin1String("qt_"); translatorFileName += QLocale::system().name(); QTranslator *translator = new QTranslator(&app); if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) app.installTranslator(translator); QWizard wizard; wizard.addPage(createIntroPage()); wizard.addPage(createRegistrationPage()); wizard.addPage(createConclusionPage()); wizard.setWindowTitle("Trivial Wizard"); wizard.show(); return app.exec(); }

Wizard Look and Feel

QWizard supports four wizard looks:
You can explicitly set the look to use using setWizardStyle() (e.g., if you want the same look on all platforms).
ClassicStyle
ModernStyle
MacStyle
AeroStyle
















Note: AeroStyle has effect only on a Windows Vista system with alpha compositing enabled. ModernStyle is used as a fallback when this condition is not met.

In addition to the wizard style, there are several options that control the look and feel of the wizard. These can be set using setOption() or setOptions(). For example, HaveHelpButton makes QWizard show a Help button along with the other wizard buttons.

You can even change the order of the wizard buttons to any arbitrary order using setButtonLayout(), and you can add up to three custom buttons (e.g., a Print button) to the button row. This is achieved by calling setButton() or setButtonText() with CustomButton1 , CustomButton2 , or CustomButton3 to set up the button, and by enabling the HaveCustomButton1 , HaveCustomButton2 , or HaveCustomButton3 options. Whenever the user clicks a custom button, customButtonClicked() is emitted. For example:

The following code example is written in c++.

        wizard()->setButtonText(QWizard::CustomButton1, tr("&Print"));
        wizard()->setOption(QWizard::HaveCustomButton1, true);
        connect(wizard(), SIGNAL(customButtonClicked(int)),
                this, SLOT(printButtonClicked()));

Elements of a Wizard Page

Wizards consist of a sequence of
QWizardPages. At any time, only one page is shown. A page has the following attributes: The diagram belows shows how QWizard renders these attributes, assuming they are all present and ModernStyle is used:

When a subTitle is set, QWizard displays it in a header, in which case it also uses the BannerPixmap and the LogoPixmap to decorate the header. The WatermarkPixmap is displayed on the left side, below the header. At the bottom, there is a row of buttons allowing the user to navigate through the pages.

The page itself (the QWizardPage widget) occupies the area between the header, the watermark, and the button row. Typically, the page is a QWizardPage on which a QGridLayout is installed, with standard child widgets (QLabels, QLineEdits, etc.).

If the wizard's style is MacStyle , the page looks radically different:


The watermark, banner, and logo pixmaps are ignored by the MacStyle . If the BackgroundPixmap is set, it is used as the background for the wizard; otherwise, a default "assistant" image is used.

The title and subtitle are set by calling QWizardPage::setTitle() and QWizardPage::setSubTitle() on the individual pages. They may be plain text or HTML (see titleFormat and subTitleFormat). The pixmaps can be set globally for the entire wizard using setPixmap(), or on a per-page basis using QWizardPage::setPixmap().

Registering and Using Fields

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. It is also possible to specify mandatory fields (i.e., fields that must be filled before the user can advance to the next page).

To register a field, call QWizardPage::registerField() field. For example:

The following code example is written in c++.

 
ClassInfoPage::ClassInfoPage(QWidget *parent)
    : QWizardPage(parent)
{
...
    classNameLabel = new QLabel(tr("&Class name:"));
    classNameLineEdit = new QLineEdit;
    classNameLabel->setBuddy(classNameLineEdit);

    baseClassLabel = new QLabel(tr("B&ase class:"));
    baseClassLineEdit = new QLineEdit;
    baseClassLabel->setBuddy(baseClassLineEdit);

    qobjectMacroCheckBox = new QCheckBox(tr("Generate Q_OBJECT ¯o"));


    registerField("className*", classNameLineEdit);
    registerField("baseClass", baseClassLineEdit);
    registerField("qobjectMacro", qobjectMacroCheckBox);
...
}
The above code registers three fields, className, baseClass, and qobjectMacro, which are associated with three child widgets. The asterisk (*) next to className denotes a mandatory field. The fields of any page are accessible from any other page. For example:

The following code example is written in c++.
void OutputFilesPage::initializePage()
{
    QString className = field("className").toString();
    headerLineEdit->setText(className.toLower() + ".h");
    implementationLineEdit->setText(className.toLower() + ".cpp");
    outputDirLineEdit->setText(QDir::convertSeparators(QDir::tempPath()));
}
Here, we call
QWizardPage::field() to access the contents of the className field (which was defined in the ClassInfoPage) and use it to initialize the OuputFilePage. The field's contents is returned as a QVariant.

When we create a field using QWizardPage::registerField(), we pass a unique field name and a widget. We can also provide a Qt property name and a "changed" signal (a signal that is emitted when the property changes) as third and fourth arguments; however, this is not necessary for the most common Qt widgets, such as QLineEdit, QCheckBox, and QComboBox, because QWizard knows which properties to look for. If an asterisk (*) is appended to the name when the property is registered, 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.

To consider a field "filled", QWizard simply checks that the field's current value doesn't equal the original value (the value it had when initializePage() was called). For QLineEdit and QAbstractSpinBox subclasses, QWizard also checks that hasAcceptableInput() returns true, to honor any validator or mask.

QWizard's mandatory field mechanism is provided for convenience. A more powerful (but also more cumbersome) alternative is to reimplement QWizardPage::isComplete() and to emit the QWizardPage::completeChanged() signal whenever the page becomes complete or incomplete.

The enabled/disabled state of the Next and/or Finish buttons is one way to perform validation on the user input. Another way is to reimplement validateCurrentPage() (or QWizardPage::validatePage()) to perform some last-minute validation (and show an error message if the user has entered incomplete or invalid information). If the function returns true, the next page is shown (or the wizard finishes); otherwise, the current page stays up.

Creating Linear Wizards

Most wizards have a linear structure, with page 1 followed by page 2 and so on until the last page. The Class Wizard example is such a wizard. With QWizard, linear wizards are created by instantiating the QWizardPages and inserting them using addPage(). By default, the pages are shown in the order in which they were added. For example:

The following code example is written in c++.
 
ClassWizard::ClassWizard(QWidget *parent)
    : QWizard(parent)
{
    addPage(new IntroPage);
    addPage(new ClassInfoPage);
    addPage(new CodeStylePage);
    addPage(new OutputFilesPage);
    addPage(new ConclusionPage);
...
}
 
When a page is about to be shown, QWizard calls initializePage() (which in turn calls QWizardPage::initializePage()) to fill the page with default values. By default, this function does nothing, but it can be reimplemented to initialize the page's contents based on other pages' fields (see the example above).

If the user presses Back, cleanupPage() is called (which in turn calls QWizardPage::cleanupPage()). The default implementation resets the page's fields to their original values (the values they had before initializePage() was called). If you want the Back button to be non-destructive and keep the values entered by the user, simply enable the IndependentPages option.

Creating Non-Linear Wizards

Some wizards are more complex in that they allow different traversal paths based on the information provided by the user. The License Wizard example illustrates this. It provides five wizard pages; depending on which options are selected, the user can reach different pages.

In complex wizards, pages are identified by IDs. These IDs are typically defined using an enum. For example:
 
class LicenseWizard : public QWizard
{
...
    enum { Page_Intro, Page_Evaluate, Page_Register, Page_Details,
           Page_Conclusion };
...
};
 
The pages are inserted using setPage(), which takes an ID and an instance of QWizardPage (or of a subclass):

The following code example is written in c++.
 
LicenseWizard::LicenseWizard(QWidget *parent)
    : QWizard(parent)
{

    setPage(Page_Intro, new IntroPage);
    setPage(Page_Evaluate, new EvaluatePage);
    setPage(Page_Register, new RegisterPage);
    setPage(Page_Details, new DetailsPage);
    setPage(Page_Conclusion, new ConclusionPage);
...
}
 
By default, the pages are shown in increasing ID order. To provide a dynamic order that depends on the options chosen by the user, we must reimplement QWizardPage::nextId(). For example:

The following code example is written in c++.
int IntroPage::nextId() const

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

int EvaluatePage::nextId() const { return LicenseWizard::Page_Conclusion; }
int RegisterPage::nextId() const { if (upgradeKeyLineEdit->text().isEmpty()) { return LicenseWizard::Page_Details; } else { return LicenseWizard::Page_Conclusion; } }
int DetailsPage::nextId() const { return LicenseWizard::Page_Conclusion; }
int ConclusionPage::nextId() const { return -1; }
It would also be possible to put all the logic in one place, in a QWizard::nextId() reimplementation. For example:
    public int nextId()
    {
        switch (currentId()) {
        case Page_Intro:
            if (QVariant.toBoolean(field("intro.evaluate"))) {
                return Page_Evaluate;
            } else {
                return Page_Register;
            }
        case Page_Evaluate:
            return Page_Conclusion;
        case Page_Register:
            if (QVariant.toString(field("register.upgradeKey")).length() == 0) {
                return Page_Details;
            } else {
                return Page_Conclusion;
            }
        case Page_Details:
            return Page_Conclusion;
        case Page_Conclusion:
        default:
            return -1;
        }
    }
To start at another page than the page with the lowest ID, call setStartId().

To test whether a page has been visited or not, call hasVisitedPage(). For example:

The following code example is written in c++.

void ConclusionPage::initializePage()
{
    QString licenseText;

    if (wizard()->hasVisitedPage(LicenseWizard::Page_Evaluate)) {
        licenseText = tr("<u>Evaluation License Agreement:</u> "
                         "You can use this software for 30 days and make one "
                         "backup, but you are not allowed to distribute it.");
    } else if (wizard()->hasVisitedPage(LicenseWizard::Page_Details)) {
        licenseText = tr("<u>First-Time License Agreement:</u> "
                         "You can use this software subject to the license "
                         "you will receive by email.");
    } else {
        licenseText = tr("<u>Upgrade License Agreement:</u> "
                         "This software is licensed under the terms of your "
                         "current license.");
    }
    bottomLabel->setText(licenseText);
}

See also:
QWizardPage, Class Wizard Example, and License Wizard Example.


Nested Class Summary
static class QWizard.WizardButton
          This enum specifies the buttons in a wizard.
static class QWizard.WizardOption
          This enum specifies various options that affect the look and feel of a wizard.
static class QWizard.WizardOptions
           
static class QWizard.WizardPixmap
          This enum specifies the pixmaps that can be associated with a page.
static class QWizard.WizardStyle
          This enum specifies the different looks supported by QWizard.
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QDialog
QDialog.DialogCode
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 QSignalEmitter.Signal1 currentIdChanged
          This signal takes 1 generic argument(s).
 QSignalEmitter.Signal1 customButtonClicked
          This signal takes 1 generic argument(s).
 QSignalEmitter.Signal0 helpRequested
          This signal is emitted when the user clicks the Help button.
 
Fields inherited from class com.trolltech.qt.gui.QDialog
accepted, finished, rejected
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QWizard()
          Constructs a wizard with the given parent and window flags.
QWizard(QWidget parent)
          Constructs a wizard with the given parent and window flags.
QWizard(QWidget parent, Qt.WindowFlags flags)
          Constructs a wizard with the given parent and window flags.
QWizard(QWidget parent, Qt.WindowType[] flags)
          This is an overloaded method provided for convenience.
 
Method Summary
 int addPage(QWizardPage page)
          Adds the given page to the wizard, and returns the page's ID.
 void back()
          Goes back to the previous page.
 QAbstractButton button(QWizard.WizardButton which)
          Returns the button corresponding to role which.
 java.lang.String buttonText(QWizard.WizardButton which)
          Returns the text on button which.
protected  void cleanupPage(int id)
          This virtual function is called by QWizard to clean up page id just before the user leaves it by clicking Back (unless the QWizard::IndependentPages option is set).
 int currentId()
          This property holds the ID of the current page.
 QWizardPage currentPage()
          Returns a pointer to the current page, or 0 if there is no current page (e.
 java.lang.Object field(java.lang.String name)
          Returns the value of the field called name.
 boolean hasVisitedPage(int id)
          Returns true if the page history contains page id; otherwise, returns false.
protected  void initializePage(int id)
          This virtual function is called by QWizard to prepare page id just before it is shown either as a result of QWizard::restart() being called, or as a result of the user clicking Next.
 void next()
          Advances to the next page.
 int nextId()
          This virtual function is called by QWizard to find out which page to show when the user clicks the Next button.
 QWizard.WizardOptions options()
          This property holds the various options that affect the look and feel of the wizard.
 QWizardPage page(int id)
          Returns the page with the given id, or 0 if there is no such page.
 java.util.List pageIds()
          Returns the list of page IDs.
 QPixmap pixmap(QWizard.WizardPixmap which)
          Returns the pixmap set for role which.
 void removePage(int id)
          Removes the page with the given id.
 void restart()
          Restarts the wizard at the start page.
 void setButton(QWizard.WizardButton which, QAbstractButton button)
          Sets the button corresponding to role which to button.
 void setButtonLayout(java.util.List layout)
          Sets the order in which buttons are displayed to layout, where layout is a list of WizardButton s.
 void setButtonText(QWizard.WizardButton which, java.lang.String text)
          Sets the text on button which to be text.
 void setField(java.lang.String name, java.lang.Object value)
          Sets the value of the field called name to value.
 void setOption(QWizard.WizardOption option)
          Sets the given option to be enabled if on is true; otherwise, clears the given option.
 void setOption(QWizard.WizardOption option, boolean on)
          Sets the given option to be enabled if on is true; otherwise, clears the given option.
 void setOptions(QWizard.WizardOption[] options)
          This is an overloaded method provided for convenience.
 void setOptions(QWizard.WizardOptions options)
          This property holds the various options that affect the look and feel of the wizard.
 void setPage(int id, QWizardPage page)
          Adds the given page to the wizard with the given id.
 void setPixmap(QWizard.WizardPixmap which, QPixmap pixmap)
          Sets the pixmap for role which to pixmap.
 void setStartId(int id)
          This property holds the ID of the first page.
 void setSubTitleFormat(Qt.TextFormat format)
          This property holds the text format used by page subtitles.
 void setTitleFormat(Qt.TextFormat format)
          This property holds the text format used by page titles.
 void setWizardStyle(QWizard.WizardStyle style)
          This property holds the look and feel of the wizard.
 int startId()
          This property holds the ID of the first page.
 Qt.TextFormat subTitleFormat()
          This property holds the text format used by page subtitles.
 boolean testOption(QWizard.WizardOption option)
          Returns true if the given option is enabled; otherwise, returns false.
 Qt.TextFormat titleFormat()
          This property holds the text format used by page titles.
 boolean validateCurrentPage()
          This virtual function is called by QWizard when the user clicks Next or Finish to perform some last-minute validation.
 java.util.List visitedPages()
          Returns the list of IDs of visited pages, in the order in which the pages were visited.
 QWizard.WizardStyle wizardStyle()
          This property holds the look and feel of the wizard.
 
Methods inherited from class com.trolltech.qt.gui.QDialog
accept, done, exec, isSizeGripEnabled, open, reject, result, setModal, setResult, setSizeGripEnabled
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, graphicsProxyWidget, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
__qt_signalInitialization
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

currentIdChanged

public final QSignalEmitter.Signal1 currentIdChanged

This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: id)>:

This signal is emitted when the current page changes, with the new current id.

See also:
currentId(), and currentPage().


customButtonClicked

public final QSignalEmitter.Signal1 customButtonClicked

This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: which)>:

This signal is emitted when the user clicks a custom button. which can be CustomButton1 , CustomButton2 , or CustomButton3 .

By default, no custom button is shown. Call setOption() with HaveCustomButton1 , HaveCustomButton2 , or HaveCustomButton3 to have one, and use setButtonText() or setButton() to configure it.

See also:
helpRequested() .


helpRequested

public final QSignalEmitter.Signal0 helpRequested
This signal is emitted when the user clicks the Help button.

By default, no Help button is shown. Call setOption(HaveHelpButton , true) to have one.

Example:

The following code example is written in c++.

  
LicenseWizard::LicenseWizard(QWidget *parent)
    : QWizard(parent)
{
...
    setOption(HaveHelpButton, true);

    connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp()));
...
}
 
void LicenseWizard::showHelp() { static QString lastHelpMessage; QString message; switch (currentId()) { case Page_Intro: message = tr("The decision you make here will affect which page you " "get to see next."); break; ... default: message = tr("This help is likely not to be of any help."); }
QMessageBox::information(this, tr("License Wizard Help"), message);
}

See also:
customButtonClicked() .

Constructor Detail

QWizard

public QWizard(QWidget parent,
               Qt.WindowType[] flags)
This is an overloaded method provided for convenience.


QWizard

public QWizard(QWidget parent)
Constructs a wizard with the given parent and window flags.

See also:
parent(), and windowFlags().


QWizard

public QWizard()
Constructs a wizard with the given parent and window flags.

See also:
parent(), and windowFlags().


QWizard

public QWizard(QWidget parent,
               Qt.WindowFlags flags)
Constructs a wizard with the given parent and window flags.

See also:
parent(), and windowFlags().

Method Detail

addPage

public final int addPage(QWizardPage page)
Adds the given page to the wizard, and returns the page's ID.

The ID is guaranteed to be larger than any other ID in the QWizard so far.

See also:
setPage(), and page().


back

public final void back()
Goes back to the previous page.

This is equivalent to pressing the Back button.

See also:
next(), accept(), reject(), and restart().


button

public final QAbstractButton button(QWizard.WizardButton which)
Returns the button corresponding to role which.

See also:
setButton(), and setButtonText().


buttonText

public final java.lang.String buttonText(QWizard.WizardButton which)
Returns the text on button which.

If a text has ben set using setButtonText(), this text is returned.

By default, the text on buttons depends on the wizardStyle. For example, on Mac OS X, the Next button is called Continue.

See also:
button(), setButton(), setButtonText(), QWizardPage::buttonText(), and QWizardPage::setButtonText().


currentId

public final int currentId()
This property holds the ID of the current page. This property cannot be set directly. To change the current page, call next(), back(), or restart().

By default, this property has a value of -1, indicating that no page is currently shown.

See also:
currentIdChanged() , and currentPage().


currentPage

public final QWizardPage currentPage()
Returns a pointer to the current page, or 0 if there is no current page (e. ., before the wizard is shown).

This is equivalent to calling page(currentId()).

See also:
page(), currentId(), and restart().


field

public final java.lang.Object field(java.lang.String name)
Returns the value of the field called name.

This function can be used to access fields on any page of the wizard.

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


hasVisitedPage

public final boolean hasVisitedPage(int id)
Returns true if the page history contains page id; otherwise, returns false.

Pressing Back marks the current page as "unvisited" again.

See also:
visitedPages().


next

public final void next()
Advances to the next page.

This is equivalent to pressing the Next or Commit button.

See also:
nextId(), back(), accept(), reject(), and restart().


options

public final QWizard.WizardOptions options()
This property holds the various options that affect the look and feel of the wizard. By default, the following options are set (depending on the platform):

See also:
wizardStyle.


page

public final QWizardPage page(int id)
Returns the page with the given id, or 0 if there is no such page.

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


pageIds

public final java.util.List pageIds()
Returns the list of page IDs.


pixmap

public final QPixmap pixmap(QWizard.WizardPixmap which)
Returns the pixmap set for role which.

By default, the only pixmap that is set is the BackgroundPixmap on Mac OS X.

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


removePage

public final void removePage(int id)
Removes the page with the given id. cleanupPage() will be called if necessary.

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


restart

public final void restart()
Restarts the wizard at the start page. This function is called automatically when the wizard is shown.

See also:
startId().


setButton

public final void setButton(QWizard.WizardButton which,
                            QAbstractButton button)
Sets the button corresponding to role which to button.

To add extra buttons to the wizard (e.g., a Print button), one way is to call setButton() with CustomButton1 to CustomButton3 , and make the buttons visible using the HaveCustomButton1 to HaveCustomButton3 options.

See also:
button(), setButtonText(), setButtonLayout(), and options.


setButtonLayout

public final void setButtonLayout(java.util.List layout)
Sets the order in which buttons are displayed to layout, where layout is a list of WizardButton s.

The default layout depends on the options (e.g., whether HelpButtonOnRight ) that are set. You can call this function if you need more control over the buttons' layout than what options already provides.

You can specify horizontal stretches in the layout using Stretch .

Example:

    public MyWizard(QWidget parent)
    {
        super(parent);
        // ...
        List<QWizard.WizardButton> layout = new LinkedList<QWizard.WizardButton>();
        layout.add(QWizard.WizardButton.Stretch);
        layout.add(QWizard.WizardButton.BackButton);
        layout.add(QWizard.WizardButton.CancelButton);
        layout.add(QWizard.WizardButton.NextButton);
        layout.add(QWizard.WizardButton.FinishButton);
        setButtonLayout(layout);
        // ...
    }

See also:
setButton(), setButtonText(), and setOptions().


setButtonText

public final void setButtonText(QWizard.WizardButton which,
                                java.lang.String text)
Sets the text on button which to be text.

By default, the text on buttons depends on the wizardStyle. For example, on Mac OS X, the Next button is called Continue.

To add extra buttons to the wizard (e.g., a Print button), one way is to call setButtonText() with CustomButton1 , CustomButton2 , or CustomButton3 to set their text, and make the buttons visible using the HaveCustomButton1 , HaveCustomButton2 , and/or HaveCustomButton3 options.

Button texts may also be set on a per-page basis using QWizardPage::setButtonText().

See also:
buttonText(), setButton(), button(), setButtonLayout(), setOptions(), and QWizardPage::setButtonText().


setField

public final void setField(java.lang.String name,
                           java.lang.Object value)
Sets the value of the field called name to value.

This function can be used to set fields on any page of the wizard.

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


setOption

public final void setOption(QWizard.WizardOption option)
Sets the given option to be enabled if on is true; otherwise, clears the given option.

See also:
options, testOption(), and setWizardStyle().


setOption

public final void setOption(QWizard.WizardOption option,
                            boolean on)
Sets the given option to be enabled if on is true; otherwise, clears the given option.

See also:
options, testOption(), and setWizardStyle().


setOptions

public final void setOptions(QWizard.WizardOption[] options)
This is an overloaded method provided for convenience.


setOptions

public final void setOptions(QWizard.WizardOptions options)
This property holds the various options that affect the look and feel of the wizard. By default, the following options are set (depending on the platform):

See also:
wizardStyle.


setPage

public final void setPage(int id,
                          QWizardPage page)
Adds the given page to the wizard with the given id.

See also:
addPage(), and page().


setPixmap

public final void setPixmap(QWizard.WizardPixmap which,
                            QPixmap pixmap)
Sets the pixmap for role which to pixmap.

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

Pixmaps can also be set for a specific page using QWizardPage::setPixmap().

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


setStartId

public final void setStartId(int id)
This property holds the ID of the first page. If this property isn't explicitly set, this property defaults to the lowest page ID in this wizard, or -1 if no page has been inserted yet.

See also:
restart(), and nextId().


setSubTitleFormat

public final void setSubTitleFormat(Qt.TextFormat format)
This property holds the text format used by page subtitles. The default format is Qt::AutoText .

See also:
QWizardPage::title, and titleFormat.


setTitleFormat

public final void setTitleFormat(Qt.TextFormat format)
This property holds the text format used by page titles. The default format is Qt::AutoText .

See also:
QWizardPage::title, and subTitleFormat.


setWizardStyle

public final void setWizardStyle(QWizard.WizardStyle style)
This property holds the look and feel of the wizard. By default, QWizard uses the AeroStyle on a Windows Vista system with alpha compositing enabled, regardless of the current widget style. If this is not the case, the default wizard style depends on the current widget style as follows: MacStyle is the default if the current widget style is QMacStyle, ModernStyle is the default if the current widget style is QWindowsStyle, and ClassicStyle is the default in all other cases.

See also:
Wizard Look and Feel, and options.


startId

public final int startId()
This property holds the ID of the first page. If this property isn't explicitly set, this property defaults to the lowest page ID in this wizard, or -1 if no page has been inserted yet.

See also:
restart(), and nextId().


subTitleFormat

public final Qt.TextFormat subTitleFormat()
This property holds the text format used by page subtitles. The default format is Qt::AutoText .

See also:
QWizardPage::title, and titleFormat.


testOption

public final boolean testOption(QWizard.WizardOption option)
Returns true if the given option is enabled; otherwise, returns false.

See also:
options, setOption(), and setWizardStyle().


titleFormat

public final Qt.TextFormat titleFormat()
This property holds the text format used by page titles. The default format is Qt::AutoText .

See also:
QWizardPage::title, and subTitleFormat.


visitedPages

public final java.util.List visitedPages()
Returns the list of IDs of visited pages, in the order in which the pages were visited.

Pressing Back marks the current page as "unvisited" again.

See also:
hasVisitedPage().


wizardStyle

public final QWizard.WizardStyle wizardStyle()
This property holds the look and feel of the wizard. By default, QWizard uses the AeroStyle on a Windows Vista system with alpha compositing enabled, regardless of the current widget style. If this is not the case, the default wizard style depends on the current widget style as follows: MacStyle is the default if the current widget style is QMacStyle, ModernStyle is the default if the current widget style is QWindowsStyle, and ClassicStyle is the default in all other cases.

See also:
Wizard Look and Feel, and options.


cleanupPage

protected void cleanupPage(int id)
This virtual function is called by QWizard to clean up page id just before the user leaves it by clicking Back (unless the QWizard::IndependentPages option is set).

The default implementation calls QWizardPage::cleanupPage() on page(id).

See also:
QWizardPage::cleanupPage(), and initializePage().


initializePage

protected void initializePage(int id)
This virtual function is called by QWizard to prepare page id just before it is shown either as a result of QWizard::restart() being called, or as a result of the user clicking Next. (However, if the QWizard::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.

The default implementation calls QWizardPage::initializePage() on page(id).

See also:
QWizardPage::initializePage(), and cleanupPage().


nextId

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

The return value is the ID of the next page, or -1 if no page follows.

The default implementation calls QWizardPage::nextId() on the currentPage().

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

See also:
QWizardPage::nextId(), and currentPage().


validateCurrentPage

public boolean validateCurrentPage()
This virtual function is called by QWizard 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 calls QWizardPage::validatePage() on the currentPage().

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

See also:
QWizardPage::validatePage(), and currentPage().