
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQWizard class provides a framework for wizards.More...
| Header: | #include <QWizard> |
| Since: | Qt 4.3 |
| Inherits: | QDialog |
| enum | WizardButton { BackButton, NextButton, CommitButton, FinishButton, ..., Stretch } |
| enum | WizardOption { IndependentPages, IgnoreSubTitles, ExtendedWatermarkPixmap, NoDefaultButton, ..., HaveCustomButton3 } |
| flags | WizardOptions |
| enum | WizardPixmap { WatermarkPixmap, LogoPixmap, BannerPixmap, BackgroundPixmap } |
| enum | WizardStyle { ClassicStyle, ModernStyle, MacStyle, AeroStyle } |
|
| QWizard(QWidget * parent = 0, Qt::WindowFlags flags = 0) | |
| ~QWizard() | |
| int | addPage(QWizardPage * page) |
| QAbstractButton * | button(WizardButton which) const |
| QString | buttonText(WizardButton which) const |
| int | currentId() const |
| QWizardPage * | currentPage() const |
| QVariant | field(const QString & name) const |
| bool | hasVisitedPage(int id) const |
| virtual int | nextId() const |
| WizardOptions | options() const |
| QWizardPage * | page(int id) const |
| QList<int> | pageIds() const |
| QPixmap | pixmap(WizardPixmap which) const |
| void | removePage(int id) |
| void | setButton(WizardButton which, QAbstractButton * button) |
| void | setButtonLayout(const QList<WizardButton> & layout) |
| void | setButtonText(WizardButton which, const QString & text) |
| void | setDefaultProperty(const char * className, const char * property, const char * changedSignal) |
| void | setField(const QString & name, const QVariant & value) |
| void | setOption(WizardOption option, bool on = true) |
| void | setOptions(WizardOptions options) |
| void | setPage(int id, QWizardPage * page) |
| void | setPixmap(WizardPixmap which, const QPixmap & pixmap) |
| void | setSideWidget(QWidget * widget) |
| void | setStartId(int id) |
| void | setSubTitleFormat(Qt::TextFormat format) |
| void | setTitleFormat(Qt::TextFormat format) |
| void | setWizardStyle(WizardStyle style) |
| QWidget * | sideWidget() const |
| int | startId() const |
| Qt::TextFormat | subTitleFormat() const |
| bool | testOption(WizardOption option) const |
| Qt::TextFormat | titleFormat() const |
| virtual bool | validateCurrentPage() |
| QList<int> | visitedPages() const |
| WizardStyle | wizardStyle() const |
| virtual void | setVisible(bool visible) |
| virtual QSize | sizeHint() const |
| void | currentIdChanged(int id) |
| void | customButtonClicked(int which) |
| void | helpRequested() |
| void | pageAdded(int id) |
| void | pageRemoved(int id) |
| virtual void | cleanupPage(int id) |
| virtual void | initializePage(int id) |
| virtual void | done(int result) |
| virtual bool | event(QEvent * event) |
| virtual void | paintEvent(QPaintEvent * event) |
| virtual void | resizeEvent(QResizeEvent * event) |
| virtual bool | winEvent(MSG * message, long * result) |
TheQWizard 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 inheritsQDialog and represents a wizard. Each page is aQWizardPage (aQWidget subclass). To create your own wizards, you can use these classes directly, or you can subclass them for more control.
Topics:
The following example illustrates how to create wizard pages and add them to a wizard. For more advanced examples, seeClass Wizard andLicense Wizard.
QWizardPage*createIntroPage(){QWizardPage*page=newQWizardPage; page->setTitle("Introduction");QLabel*label=newQLabel("This wizard will help you register your copy ""of Super Product Two."); label->setWordWrap(true);QVBoxLayout*layout=newQVBoxLayout; 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=newQTranslator(&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");#ifdef Q_OS_SYMBIAN wizard.showMaximized();#else wizard.show();#endifreturn app.exec();}
QWizard supports four wizard looks:
You can explicitly set the look to use usingsetWizardStyle() (e.g., if you want the same look on all platforms).
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 usingsetOption() orsetOptions(). For example,HaveHelpButton makesQWizard show aHelp button along with the other wizard buttons.
You can even change the order of the wizard buttons to any arbitrary order usingsetButtonLayout(), and you can add up to three custom buttons (e.g., aPrint button) to the button row. This is achieved by callingsetButton() orsetButtonText() withCustomButton1,CustomButton2, orCustomButton3 to set up the button, and by enabling theHaveCustomButton1,HaveCustomButton2, orHaveCustomButton3 options. Whenever the user clicks a custom button,customButtonClicked() is emitted. For example:
wizard()->setButtonText(QWizard::CustomButton1, tr("&Print")); wizard()->setOption(QWizard::HaveCustomButton1,true); connect(wizard(), SIGNAL(customButtonClicked(int)),this, SLOT(printButtonClicked()));
Wizards consist of a sequence ofQWizardPages. At any time, only one page is shown. A page has the following attributes:
The diagram belows shows howQWizard renders these attributes, assuming they are all present andModernStyle is used:

When asubTitle is set,QWizard displays it in a header, in which case it also uses theBannerPixmap and theLogoPixmap to decorate the header. TheWatermarkPixmap 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 (theQWizardPage widget) occupies the area between the header, the watermark, and the button row. Typically, the page is aQWizardPage on which aQGridLayout is installed, with standard child widgets (QLabels,QLineEdits, etc.).
If the wizard's style isMacStyle, the page looks radically different:

The watermark, banner, and logo pixmaps are ignored by theMacStyle. If theBackgroundPixmap 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 callingQWizardPage::setTitle() andQWizardPage::setSubTitle() on the individual pages. They may be plain text or HTML (seetitleFormat andsubTitleFormat). The pixmaps can be set globally for the entire wizard usingsetPixmap(), or on a per-page basis usingQWizardPage::setPixmap().
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., aQLineEdit) 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, callQWizardPage::registerField() field. For example:
ClassInfoPage::ClassInfoPage(QWidget*parent) :QWizardPage(parent){ ... classNameLabel=newQLabel(tr("&Class name:")); classNameLineEdit=newQLineEdit; classNameLabel->setBuddy(classNameLineEdit); baseClassLabel=newQLabel(tr("B&ase class:")); baseClassLineEdit=newQLineEdit; baseClassLabel->setBuddy(baseClassLineEdit); qobjectMacroCheckBox=newQCheckBox(tr("Generate Q_OBJECT ¯o")); registerField("className*", classNameLineEdit); registerField("baseClass", baseClassLineEdit); registerField("qobjectMacro", qobjectMacroCheckBox); ...}
The above code registers three fields,className,baseClass, andqobjectMacro, which are associated with three child widgets. The asterisk (*) next toclassName denotes a mandatory field.
The fields of any page are accessible from any other page. 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()));}
Here, we callQWizardPage::field() to access the contents of theclassName field (which was defined in theClassInfoPage) and use it to initialize theOuputFilePage. The field's contents is returned as aQVariant.
When we create a field usingQWizardPage::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 asQLineEdit,QCheckBox, andQComboBox, becauseQWizard knows which properties to look for.
If an asterisk (*) is appended to the name when the property is registered, the field is amandatory field. When a page has mandatory fields, theNext and/orFinish 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 wheninitializePage() was called). ForQLineEdit andQAbstractSpinBox subclasses,QWizard also checks thathasAcceptableInput() 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 reimplementQWizardPage::isComplete() and to emit theQWizardPage::completeChanged() signal whenever the page becomes complete or incomplete.
The enabled/disabled state of theNext and/orFinish buttons is one way to perform validation on the user input. Another way is to reimplementvalidateCurrentPage() (orQWizardPage::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.
Most wizards have a linear structure, with page 1 followed by page 2 and so on until the last page. TheClass Wizard example is such a wizard. WithQWizard, linear wizards are created by instantiating theQWizardPages and inserting them usingaddPage(). By default, the pages are shown in the order in which they were added. For example:
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 callsinitializePage() (which in turn callsQWizardPage::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 theexample above).
If the user pressesBack,cleanupPage() is called (which in turn callsQWizardPage::cleanupPage()). The default implementation resets the page's fields to their original values (the values they had beforeinitializePage() was called). If you want theBack button to be non-destructive and keep the values entered by the user, simply enable theIndependentPages option.
Some wizards are more complex in that they allow different traversal paths based on the information provided by the user. TheLicense 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 :publicQWizard{ ...enum { Page_Intro, Page_Evaluate, Page_Register, Page_Details, Page_Conclusion }; ...};
The pages are inserted usingsetPage(), which takes an ID and an instance ofQWizardPage (or of a subclass):
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 reimplementQWizardPage::nextId(). For example:
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 aQWizard::nextId() reimplementation. For example:
int LicenseWizard::nextId()const{switch (currentId()) {case Page_Intro:if (field("intro.evaluate").toBool()) {return Page_Evaluate; }else {return Page_Register; }case Page_Evaluate:return Page_Conclusion;case Page_Register:if (field("register.upgradeKey").toString().isEmpty()) {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, callsetStartId().
To test whether a page has been visited or not, callhasVisitedPage(). For example:
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."); }elseif (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 alsoQWizardPage,Class Wizard Example, andLicense Wizard Example.
This enum specifies the buttons in a wizard.
| Constant | Value | Description |
|---|---|---|
QWizard::BackButton | 0 | TheBack button (Go Back on Mac OS X) |
QWizard::NextButton | 1 | TheNext button (Continue on Mac OS X) |
QWizard::CommitButton | 2 | TheCommit button |
QWizard::FinishButton | 3 | TheFinish button (Done on Mac OS X) |
QWizard::CancelButton | 4 | TheCancel button (see alsoNoCancelButton) |
QWizard::HelpButton | 5 | TheHelp button (see alsoHaveHelpButton) |
QWizard::CustomButton1 | 6 | The first user-defined button (see alsoHaveCustomButton1) |
QWizard::CustomButton2 | 7 | The second user-defined button (see alsoHaveCustomButton2) |
QWizard::CustomButton3 | 8 | The third user-defined button (see alsoHaveCustomButton3) |
The following value is only useful when callingsetButtonLayout():
| Constant | Value | Description |
|---|---|---|
QWizard::Stretch | 9 | A horizontal stretch in the button layout |
See alsosetButton(),setButtonText(),setButtonLayout(), andcustomButtonClicked().
This enum specifies various options that affect the look and feel of a wizard.
| Constant | Value | Description |
|---|---|---|
QWizard::IndependentPages | 0x00000001 | The pages are independent of each other (i.e., they don't derive values from each other). |
QWizard::IgnoreSubTitles | 0x00000002 | Don't show any subtitles, even if they are set. |
QWizard::ExtendedWatermarkPixmap | 0x00000004 | Extend anyWatermarkPixmap all the way down to the window's edge. |
QWizard::NoDefaultButton | 0x00000008 | Don't make theNext orFinish button the dialog'sdefault button. |
QWizard::NoBackButtonOnStartPage | 0x00000010 | Don't show theBack button on the start page. |
QWizard::NoBackButtonOnLastPage | 0x00000020 | Don't show theBack button on the last page. |
QWizard::DisabledBackButtonOnLastPage | 0x00000040 | Disable theBack button on the last page. |
QWizard::HaveNextButtonOnLastPage | 0x00000080 | Show the (disabled)Next button on the last page. |
QWizard::HaveFinishButtonOnEarlyPages | 0x00000100 | Show the (disabled)Finish button on non-final pages. |
QWizard::NoCancelButton | 0x00000200 | Don't show theCancel button. |
QWizard::CancelButtonOnLeft | 0x00000400 | Put theCancel button on the left ofBack (rather than on the right ofFinish orNext). |
QWizard::HaveHelpButton | 0x00000800 | Show theHelp button. |
QWizard::HelpButtonOnRight | 0x00001000 | Put theHelp button on the far right of the button layout (rather than on the far left). |
QWizard::HaveCustomButton1 | 0x00002000 | Show the first user-defined button (CustomButton1). |
QWizard::HaveCustomButton2 | 0x00004000 | Show the second user-defined button (CustomButton2). |
QWizard::HaveCustomButton3 | 0x00008000 | Show the third user-defined button (CustomButton3). |
The WizardOptions type is a typedef forQFlags<WizardOption>. It stores an OR combination of WizardOption values.
See alsosetOptions(),setOption(), andtestOption().
This enum specifies the pixmaps that can be associated with a page.
| Constant | Value | Description |
|---|---|---|
QWizard::WatermarkPixmap | 0 | The tall pixmap on the left side of aClassicStyle orModernStyle page |
QWizard::LogoPixmap | 1 | The small pixmap on the right side of aClassicStyle orModernStyle page header |
QWizard::BannerPixmap | 2 | The pixmap that occupies the background of aModernStyle page header |
QWizard::BackgroundPixmap | 3 | The pixmap that occupies the background of aMacStyle wizard |
See alsosetPixmap(),QWizardPage::setPixmap(), andElements of a Wizard Page.
This enum specifies the different looks supported byQWizard.
| Constant | Value | Description |
|---|---|---|
QWizard::ClassicStyle | 0 | Classic Windows look |
QWizard::ModernStyle | 1 | Modern Windows look |
QWizard::MacStyle | 2 | Mac OS X look |
QWizard::AeroStyle | 3 | Windows Aero look |
See alsosetWizardStyle(),WizardOption, andWizard Look and Feel.
This property holds the ID of the current page.
This property cannot be set directly. To change the current page, callnext(),back(), orrestart().
By default, this property has a value of -1, indicating that no page is currently shown.
Access functions:
| int | currentId() const |
Notifier signal:
| void | currentIdChanged(int id) |
See alsocurrentIdChanged() andcurrentPage().
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):
Access functions:
| WizardOptions | options() const |
| void | setOptions(WizardOptions options) |
See alsowizardStyle.
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.
Access functions:
| int | startId() const |
| void | setStartId(int id) |
See alsorestart() andnextId().
This property holds the text format used by page subtitles.
The default format isQt::AutoText.
Access functions:
| Qt::TextFormat | subTitleFormat() const |
| void | setSubTitleFormat(Qt::TextFormat format) |
See alsoQWizardPage::title andtitleFormat.
This property holds the text format used by page titles.
The default format isQt::AutoText.
Access functions:
| Qt::TextFormat | titleFormat() const |
| void | setTitleFormat(Qt::TextFormat format) |
See alsoQWizardPage::title andsubTitleFormat.
This property holds the look and feel of the wizard.
By default,QWizard uses theAeroStyle 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 isQMacStyle,ModernStyle is the default if the current widget style isQWindowsStyle, andClassicStyle is the default in all other cases.
Access functions:
| WizardStyle | wizardStyle() const |
| void | setWizardStyle(WizardStyle style) |
See alsoWizard Look and Feel andoptions.
Constructs a wizard with the givenparent and windowflags.
See alsoparent() andwindowFlags().
Destroys the wizard and its pages, releasing any allocated resources.
Adds the givenpage to the wizard, and returns the page's ID.
The ID is guaranteed to be larger than any other ID in theQWizard so far.
See alsosetPage(),page(), andpageAdded().
[slot]void QWizard::back()Goes back to the previous page.
This is equivalent to pressing theBack button.
See alsonext(),accept(),reject(), andrestart().
Returns the button corresponding to rolewhich.
See alsosetButton() andsetButtonText().
Returns the text on buttonwhich.
If a text has ben set usingsetButtonText(), this text is returned.
By default, the text on buttons depends on thewizardStyle. For example, on Mac OS X, theNext button is calledContinue.
See alsobutton(),setButton(),setButtonText(),QWizardPage::buttonText(), andQWizardPage::setButtonText().
[virtual protected]void QWizard::cleanupPage(int id)This virtual function is called byQWizard to clean up pageid just before the user leaves it by clickingBack (unless theQWizard::IndependentPages option is set).
The default implementation callsQWizardPage::cleanupPage() on page(id).
See alsoQWizardPage::cleanupPage() andinitializePage().
Returns a pointer to the current page, or 0 if there is no current page (e.g., before the wizard is shown).
This is equivalent to calling page(currentId()).
See alsopage(),currentId(), andrestart().
[signal]void QWizard::customButtonClicked(int which)This signal is emitted when the user clicks a custom button.which can beCustomButton1,CustomButton2, orCustomButton3.
By default, no custom button is shown. CallsetOption() withHaveCustomButton1,HaveCustomButton2, orHaveCustomButton3 to have one, and usesetButtonText() orsetButton() to configure it.
See alsohelpRequested().
[virtual protected]void QWizard::done(int result)Reimplemented fromQDialog::done().
[virtual protected]bool QWizard::event(QEvent * event)Reimplemented fromQObject::event().
Returns the value of the field calledname.
This function can be used to access fields on any page of the wizard.
See alsoQWizardPage::registerField(),QWizardPage::field(), andsetField().
Returns true if the page history contains pageid; otherwise, returns false.
PressingBack marks the current page as "unvisited" again.
See alsovisitedPages().
[signal]void QWizard::helpRequested()This signal is emitted when the user clicks theHelp button.
By default, noHelp button is shown. CallsetOption(HaveHelpButton, true) to have one.
Example:
LicenseWizard::LicenseWizard(QWidget*parent) :QWizard(parent){ ... setOption(HaveHelpButton,true); connect(this, SIGNAL(helpRequested()),this, SLOT(showHelp())); ...}void LicenseWizard::showHelp(){staticQString 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 alsocustomButtonClicked().
[virtual protected]void QWizard::initializePage(int id)This virtual function is called byQWizard to prepare pageid just before it is shown either as a result ofQWizard::restart() being called, or as a result of the user clickingNext. (However, if theQWizard::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 callsQWizardPage::initializePage() on page(id).
See alsoQWizardPage::initializePage() andcleanupPage().
[slot]void QWizard::next()Advances to the next page.
This is equivalent to pressing theNext orCommit button.
See alsonextId(),back(),accept(),reject(), andrestart().
[virtual]int QWizard::nextId() constThis virtual function is called byQWizard to find out which page to show when the user clicks theNext button.
The return value is the ID of the next page, or -1 if no page follows.
The default implementation callsQWizardPage::nextId() on thecurrentPage().
By reimplementing this function, you can specify a dynamic page order.
See alsoQWizardPage::nextId() andcurrentPage().
Returns the page with the givenid, or 0 if there is no such page.
See alsoaddPage() andsetPage().
[signal]void QWizard::pageAdded(int id)This signal is emitted whenever a page is added to the wizard. The page'sid is passed as parameter.
This function was introduced in Qt 4.7.
See alsoaddPage(),setPage(), andstartId().
Returns the list of page IDs.
This function was introduced in Qt 4.5.
[signal]void QWizard::pageRemoved(int id)This signal is emitted whenever a page is removed from the wizard. The page'sid is passed as parameter.
This function was introduced in Qt 4.7.
See alsoremovePage() andstartId().
[virtual protected]void QWizard::paintEvent(QPaintEvent * event)Reimplemented fromQWidget::paintEvent().
Returns the pixmap set for rolewhich.
By default, the only pixmap that is set is theBackgroundPixmap on Mac OS X.
See alsosetPixmap(),QWizardPage::pixmap(), andElements of a Wizard Page.
Removes the page with the givenid.cleanupPage() will be called if necessary.
Note:Removing a page may influence the value of thestartId property.
This function was introduced in Qt 4.5.
See alsoaddPage(),setPage(),pageRemoved(), andstartId().
[virtual protected]void QWizard::resizeEvent(QResizeEvent * event)Reimplemented fromQWidget::resizeEvent().
[slot]void QWizard::restart()Restarts the wizard at the start page. This function is called automatically when the wizard is shown.
See alsostartId().
Sets the button corresponding to rolewhich tobutton.
To add extra buttons to the wizard (e.g., aPrint button), one way is to call setButton() withCustomButton1 toCustomButton3, and make the buttons visible using theHaveCustomButton1 toHaveCustomButton3 options.
See alsobutton(),setButtonText(),setButtonLayout(), andoptions.
Sets the order in which buttons are displayed tolayout, wherelayout is a list ofWizardButtons.
The default layout depends on the options (e.g., whetherHelpButtonOnRight) that are set. You can call this function if you need more control over the buttons' layout than whatoptions already provides.
You can specify horizontal stretches in the layout usingStretch.
Example:
MyWizard::MyWizard(QWidget*parent) :QWizard(parent){...QList<QWizard::WizardButton> layout; layout<<QWizard::Stretch<<QWizard::BackButton<<QWizard::CancelButton<<QWizard::NextButton<<QWizard::FinishButton; setButtonLayout(layout);...}
See alsosetButton(),setButtonText(), andsetOptions().
Sets the text on buttonwhich to betext.
By default, the text on buttons depends on thewizardStyle. For example, on Mac OS X, theNext button is calledContinue.
To add extra buttons to the wizard (e.g., aPrint button), one way is to call setButtonText() withCustomButton1,CustomButton2, orCustomButton3 to set their text, and make the buttons visible using theHaveCustomButton1,HaveCustomButton2, and/orHaveCustomButton3 options.
Button texts may also be set on a per-page basis usingQWizardPage::setButtonText().
See alsobuttonText(),setButton(),button(),setButtonLayout(),setOptions(), andQWizardPage::setButtonText().
Sets the default property forclassName to beproperty, and the associated change signal to bechangedSignal.
The default property is used when an instance ofclassName (or of one of its subclasses) is passed toQWizardPage::registerField() and no property is specified.
QWizard knows the most common Qt widgets. For these (or their subclasses), you don't need to specify aproperty or achangedSignal. The table below lists these widgets:
See alsoQWizardPage::registerField().
Sets the value of the field calledname tovalue.
This function can be used to set fields on any page of the wizard.
See alsoQWizardPage::registerField(),QWizardPage::setField(), andfield().
Sets the givenoption to be enabled ifon is true; otherwise, clears the givenoption.
See alsooptions,testOption(), andsetWizardStyle().
Adds the givenpage to the wizard with the givenid.
Note:Adding a page may influence the value of thestartId property in case it was not set explicitly.
See alsoaddPage(),page(), andpageAdded().
Sets the pixmap for rolewhich topixmap.
The pixmaps are used byQWizard when displaying a page. Which pixmaps are actually used depend on thewizard style.
Pixmaps can also be set for a specific page usingQWizardPage::setPixmap().
See alsopixmap(),QWizardPage::setPixmap(), andElements of a Wizard Page.
Sets the givenwidget to be shown on the left side of the wizard. For styles which use theWatermarkPixmap (ClassicStyle andModernStyle) the side widget is displayed on top of the watermark, for other styles or when the watermark is not provided the side widget is displayed on the left side of the wizard.
Passing 0 shows no side widget.
When thewidget is not 0 the wizard reparents it.
Any previous side widget is hidden.
You may call setSideWidget() with the same widget at different times.
All widgets set here will be deleted by the wizard when it is destroyed unless you separately reparent the widget after setting some other side widget (or 0).
By default, no side widget is present.
This function was introduced in Qt 4.7.
See alsosideWidget().
[virtual]void QWizard::setVisible(bool visible)Reimplemented fromQWidget::setVisible().
Returns the widget on the left side of the wizard or 0.
By default, no side widget is present.
This function was introduced in Qt 4.7.
See alsosetSideWidget().
[virtual]QSize QWizard::sizeHint() constReimplemented fromQWidget::sizeHint().
Returns true if the givenoption is enabled; otherwise, returns false.
See alsooptions,setOption(), andsetWizardStyle().
[virtual]bool QWizard::validateCurrentPage()This virtual function is called byQWizard when the user clicksNext orFinish 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 callsQWizardPage::validatePage() on thecurrentPage().
When possible, it is usually better style to disable theNext orFinish button (by specifyingmandatory fields or by reimplementingQWizardPage::isComplete()) than to reimplement validateCurrentPage().
See alsoQWizardPage::validatePage() andcurrentPage().
Returns the list of IDs of visited pages, in the order in which the pages were visited.
PressingBack marks the current page as "unvisited" again.
See alsohasVisitedPage().
[virtual protected]bool QWizard::winEvent(MSG * message,long * result)Reimplemented fromQWidget::winEvent().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.