QWizardPage露
The
QWizardPageclass is the base class for wizard pages. More鈥

Synopsis露
Functions露
def
buttonText(which)def
field(name)def
isCommitPage()def
isFinalPage()def
pixmap(which)def
registerField(name, widget[, property=None[, changedSignal=None]])def
setButtonText(which, text)def
setCommitPage(commitPage)def
setField(name, value)def
setFinalPage(finalPage)def
setPixmap(which, pixmap)def
setSubTitle(subTitle)def
setTitle(title)def
subTitle()def
title()def
wizard()
Virtual functions露
def
cleanupPage()def
initializePage()def
isComplete()def
nextId()def
validatePage()
Signals露
def
completeChanged()
Detailed Description露
QWizardrepresents a wizard. Each page is aQWizardPage. When you create your own wizards, you can useQWizardPagedirectly, or you can subclass it for more control.A page has the following attributes, which are rendered by
QWizard: atitle, asubTitle, and aset of pixmaps. SeeElements of a Wizard Pagefor details. Once a page is added to the wizard (usingaddPage()orsetPage()),wizard()returns a pointer to the associatedQWizardobject.Page provides five virtual functions that can be reimplemented to provide custom behavior:
initializePage()is called to initialize the page鈥檚 contents when the user clicks the wizard鈥檚 Next button. If you want to derive the page鈥檚 default from what the user entered on previous pages, this is the function to reimplement.
cleanupPage()is called to reset the page鈥檚 contents when the user clicks the wizard鈥檚 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 whencreating 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 reimplementisComplete(), also make sure thatcompleteChanged()is emitted whenever the complete state changes.Normally, the Next button and the Finish button of a wizard are mutually exclusive. If
isFinalPage()returnstrue, Finish is available; otherwise, Next is available. By default,isFinalPage()is true only whennextId()returns -1. If you want to show Next and Final simultaneously for a page (letting the user perform an 鈥渆arly finish鈥), callsetFinalPage(true) on that page. For wizards that support early finishes, you might also want to set theHaveNextButtonOnLastPageandHaveFinishButtonOnEarlyPagesoptions 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,
QWizardsupports a"field" mechanismthat allows you to register a field (e.g., aQLineEdit) 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 inQWizardor having the pages know explicitly about each other. Fields are registered usingregisterField()and can be accessed at any time usingfield()andsetField().
- class PySide2.QtWidgets.QWizardPage([parent=None])露
- param parent:
Constructs a wizard page with the given
parent.When the page is inserted into a wizard using
addPage()orsetPage(), the parent is automatically set to be the wizard.See also
- PySide2.QtWidgets.QWizardPage.buttonText(which)露
- Parameters:
which 鈥
WizardButton- Return type:
str
Returns the text on button
whichon this page.If a text has ben set using
setButtonText(), this text is returned. Otherwise, if a text has been set usingsetButtonText(), this text is returned.By default, the text on buttons depends on the
wizardStyle. For example, on macOS, the Next button is called Continue.See also
- PySide2.QtWidgets.QWizardPage.cleanupPage()露
This virtual function is called by
cleanupPage()when the user leaves the page by clicking Back (unless theIndependentPagesoption is set).The default implementation resets the page鈥檚 fields to their original values (the values they had before
initializePage()was called).See also
cleanupPage()initializePage()IndependentPages
- PySide2.QtWidgets.QWizardPage.completeChanged()露
- PySide2.QtWidgets.QWizardPage.field(name)露
- Parameters:
name 鈥 str
- Return type:
object
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()->``name`` :meth:` <PySide2.QtWidgets.QWizard.field>` ).Example:
def initializePage(self): className = field("className") self.headerLineEdit.setText(className.lower() + ".h") self.implementationLineEdit.setText(className.lower() + ".cpp") self.outputDirLineEdit.setText(QDir.convertSeparators(QDir.tempPath()))
See also
- PySide2.QtWidgets.QWizardPage.initializePage()露
This virtual function is called by
initializePage()to prepare the page just before it is shown either as a result ofrestart()being called, or as a result of the user clicking Next. (However, if theIndependentPagesoption is set, this function is only called the first time the page is shown.)By reimplementing this function, you can ensure that the page鈥檚 fields are properly initialized based on fields from previous pages. For example:
def initializePage(self): className = field("className") self.headerLineEdit.setText(className.lower() + ".h") self.implementationLineEdit.setText(className.lower() + ".cpp") self.outputDirLineEdit.setText(QDir.convertSeparators(QDir.tempPath()))
The default implementation does nothing.
See also
initializePage()cleanupPage()IndependentPages
- PySide2.QtWidgets.QWizardPage.isCommitPage()露
- Return type:
bool
Returns
trueif this page is a commit page; otherwise returnsfalse.See also
- PySide2.QtWidgets.QWizardPage.isComplete()露
- Return type:
bool
This virtual function is called by
QWizardto determine whether the Next or Finish button should be enabled or disabled.The default implementation returns
trueif allmandatory fieldsare filled; otherwise, it returnsfalse.If you reimplement this function, make sure to emit
completeChanged(), from the rest of your implementation, whenever the value of changes. This ensures thatQWizardupdates the enabled or disabled state of its buttons. An example of the reimplementation is available here .See also
- PySide2.QtWidgets.QWizardPage.isFinalPage()露
- Return type:
bool
This function is called by
QWizardto determine whether the Finish button should be shown for this page or not.By default, it returns
trueif there is no next page (i.e.,nextId()returns -1); otherwise, it returnsfalse.By explicitly calling
setFinalPage(true), you can let the user perform an 鈥渆arly finish鈥.See also
isComplete()HaveFinishButtonOnEarlyPages
- PySide2.QtWidgets.QWizardPage.nextId()露
- Return type:
int
This virtual function is called by
nextId()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.
By default, this function returns the lowest ID greater than the ID of the current page, or -1 if there is no such ID.
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
- PySide2.QtWidgets.QWizardPage.pixmap(which)露
- Parameters:
which 鈥
WizardPixmap- Return type:
Returns the pixmap set for role
which.Pixmaps can also be set for the entire wizard using
setPixmap(), in which case they apply for all pages that don鈥檛 specify a pixmap.See also
setPixmap()pixmap()Elements of a Wizard Page
- PySide2.QtWidgets.QWizardPage.registerField(name, widget[, property=None[, changedSignal=None]])露
- Parameters:
name 鈥 str
widget 鈥
PySide2.QtWidgets.QWidgetproperty 鈥 str
changedSignal 鈥 str
Creates a field called
nameassociated with the givenpropertyof the givenwidget. From then on, that property becomes accessible usingfield()andsetField().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
QWizardor having the pages know explicitly about each other.If
nameends 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 achangedSignalto be specified, to tellQWizardto recheck the value stored by the mandatory field.QWizardknows the most common Qt widgets. For these (or their subclasses), you don鈥檛 need to specify apropertyor achangedSignal. The table below lists these widgets:Widget
Property
Change Notification Signal
bool
checkedint
valueint
currentIndexQDateTimedateTimeQStringtextint
currentRowint
valueYou can use
setDefaultProperty()to add entries to this table or to override existing entries.To consider a field 鈥渇illed鈥,
QWizardsimply checks that their current value doesn鈥檛 equal their original value (the value they had beforeinitializePage()was called). ForQLineEdit, it also checks thathasAcceptableInput()returns true, to honor any validator or mask.QWizard鈥榮 mandatory field mechanism is provided for convenience. It can be bypassed by reimplementingisComplete().See also
- PySide2.QtWidgets.QWizardPage.setButtonText(which, text)露
- Parameters:
which 鈥
WizardButtontext 鈥 str
Sets the text on button
whichto betexton this page.By default, the text on buttons depends on the
wizardStyle, but may be redefined for the wizard as a whole usingsetButtonText().See also
- PySide2.QtWidgets.QWizardPage.setCommitPage(commitPage)露
- Parameters:
commitPage 鈥 bool
Sets this page to be a commit page if
commitPageis true; otherwise, sets it to be a normal page.A commit page is a page that represents an action which cannot be undone by clicking Back or Cancel.
A Commit button replaces the Next button on a commit page. Clicking this button simply calls
next()just like clicking Next does.A page entered directly from a commit page has its Back button disabled.
See also
- PySide2.QtWidgets.QWizardPage.setField(name, value)露
- Parameters:
name 鈥 str
value 鈥 object
Sets the value of the field called
nametovalue.This function can be used to set fields on any page of the wizard. It is equivalent to calling
wizard()->``name`` :meth:` <PySide2.QtWidgets.QWizard.setField>` ,value).See also
- PySide2.QtWidgets.QWizardPage.setFinalPage(finalPage)露
- Parameters:
finalPage 鈥 bool
Explicitly sets this page to be final if
finalPageis true.After calling (true),
isFinalPage()returnstrueand the Finish button is visible (and enabled ifisComplete()returns true).After calling (false),
isFinalPage()returnstrueifnextId()returns -1; otherwise, it returnsfalse.See also
isFinalPage()isComplete()HaveFinishButtonOnEarlyPages
- PySide2.QtWidgets.QWizardPage.setPixmap(which, pixmap)露
- Parameters:
which 鈥
WizardPixmappixmap 鈥
PySide2.QtGui.QPixmap
Sets the pixmap for role
whichtopixmap.The pixmaps are used by
QWizardwhen displaying a page. Which pixmaps are actually used depend on thewizard style.Pixmaps can also be set for the entire wizard using
setPixmap(), in which case they apply for all pages that don鈥檛 specify a pixmap.See also
pixmap()setPixmap()Elements of a Wizard Page
- PySide2.QtWidgets.QWizardPage.setSubTitle(subTitle)露
- Parameters:
subTitle 鈥 str
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. InClassicStyleandModernStyle, using subtitles is necessary to make the header appear. InMacStyle, 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
subTitleFormatproperty.By default, this property contains an empty string.
See also
titleIgnoreSubTitlesElements of a Wizard Page
- PySide2.QtWidgets.QWizardPage.setTitle(title)露
- Parameters:
title 鈥 str
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
titleFormatproperty.By default, this property contains an empty string.
See also
subTitleElements of a Wizard Page
- PySide2.QtWidgets.QWizardPage.subTitle()露
- Return type:
str
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. InClassicStyleandModernStyle, using subtitles is necessary to make the header appear. InMacStyle, 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
subTitleFormatproperty.By default, this property contains an empty string.
See also
titleIgnoreSubTitlesElements of a Wizard Page
- PySide2.QtWidgets.QWizardPage.title()露
- Return type:
str
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
titleFormatproperty.By default, this property contains an empty string.
See also
subTitleElements of a Wizard Page
- PySide2.QtWidgets.QWizardPage.validatePage()露
- Return type:
bool
This virtual function is called by
validateCurrentPage()when the user clicks Next or Finish to perform some last-minute validation. If it returnstrue, 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 fieldsor reimplementingisComplete()) than to reimplement .See also
漏 2022 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 the GNU 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.