PySide6.QtWidgets.QWizardPage¶
- class QWizardPage¶
- The - QWizardPageclass is the base class for wizard pages. More…- Synopsis¶- Properties¶- Methods¶- def - __init__()
- def - buttonText()
- def - field()
- def - isCommitPage()
- def - isFinalPage()
- def - pixmap()
- def - registerField()
- def - setButtonText()
- def - setCommitPage()
- def - setField()
- def - setFinalPage()
- def - setPixmap()
- def - setSubTitle()
- def - setTitle()
- def - subTitle()
- def - title()
- def - wizard()
 - Virtual methods¶- def - cleanupPage()
- def - initializePage()
- def - isComplete()
- def - nextId()
- def - validatePage()
 - Signals¶- Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- QWizardrepresents a wizard. Each page is a- QWizardPage. When you create your own wizards, you can use- QWizardPagedirectly, or you can subclass it for more control.- A page has the following attributes, which are rendered by - QWizard: a- title, a- subTitle, and a- set of pixmaps. See- Elements of a Wizard Pagefor details. Once a page is added to the wizard (using- addPage()or- setPage()),- wizard()returns a pointer to the associated- QWizardobject.- Page provides five virtual functions that can be reimplemented to provide custom behavior: - initializePage()is called to initialize the page’s contents when the user clicks the wizard’s Next button. If you want to derive the page’s default from what the user entered on previous pages, this is the function to reimplement.
- cleanupPage()is called to reset the page’s contents when the user clicks the wizard’s Back button.
- validatePage()validates the page when the user clicks Next or Finish. It is often used to show an error message if the user has entered incomplete or invalid information.
- nextId()returns the ID of the next page. It is useful when- creating non-linear wizards, which allow different traversal paths based on the information provided by the user.
- isComplete()is called to determine whether the Next and/or Finish button should be enabled or disabled. If you reimplement- isComplete(), also make sure that- completeChanged()is emitted whenever the complete state changes.
 - Normally, the Next button and the Finish button of a wizard are mutually exclusive. If - isFinalPage()returns- true, Finish is available; otherwise, Next is available. By default,- isFinalPage()is true only when- nextId()returns -1. If you want to show Next and Final simultaneously for a page (letting the user perform an “early finish”), call- setFinalPage(true) on that page. For wizards that support early finishes, you might also want to set the- HaveNextButtonOnLastPageand- HaveFinishButtonOnEarlyPagesoptions 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., 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- QWizardor 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 - QWizardTrivial Wizard Example License Wizard Example- Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property 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. In- ClassicStyleand- 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 - subTitleFormatproperty.- By default, this property contains an empty string. - See also - title- IgnoreSubTitles- Elements of a Wizard Page- Access functions:
 - property 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 - subTitle- Elements of a Wizard Page- Access functions:
 - Constructs a wizard page with the given - parent.- When the page is inserted into a wizard using - addPage()or- setPage(), the parent is automatically set to be the wizard.- See also - 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 using- setButtonText(), 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 - cleanupPage()¶
 - This virtual function is called by - cleanupPage()when the user leaves the page by clicking Back (unless the- IndependentPagesoption is set).- The default implementation resets the page’s fields to their original values (the values they had before - initializePage()was called).- completeChanged()¶
 - 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- QWizardupdates the enabled or disabled state of its buttons.- See also - field(name)¶
- Parameters:
- name – str 
- Return type:
- object 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - 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:` <PySide6.QtWidgets.QWizard.field>` ).- Example: - emailAddress = field("details.email").toString() licenseText = tr("<u>First-Time License Agreement:</u> " "You can use self software subject to the license " "you will receive by email sent to %1.").arg(emailAddress) - See also - initializePage()¶
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - This virtual function is called by - initializePage()to prepare the page just before it is shown either as a result of- restart()being called, or as a result of the user clicking Next. (However, if the- IndependentPagesoption 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: - def initializePage(self): licenseText = QString() if wizard().hasVisitedPage(LicenseWizard.Page_Evaluate): licenseText = tr("<u>Evaluation License Agreement:</u> " "You can use self software for 30 days and make one " "backup, but you are not allowed to distribute it.") elif wizard().hasVisitedPage(LicenseWizard.Page_Details): emailAddress = field("details.email").toString() licenseText = tr("<u>First-Time License Agreement:</u> " "You can use self software subject to the license " "you will receive by email sent to %1.").arg(emailAddress) else: licenseText = tr("<u>Upgrade License Agreement:</u> " "This software is licensed under the terms of your " "current license.") bottomLabel.setText(licenseText) - The default implementation does nothing. - isCommitPage()¶
- Return type:
- bool 
 
 - Returns - trueif this page is a commit page; otherwise returns- false.- See also - 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 all- mandatory fieldsare filled; otherwise, it returns- false.- If you reimplement this function, make sure to emit - completeChanged(), from the rest of your implementation, whenever the value of isComplete() changes. This ensures that- QWizardupdates the enabled or disabled state of its buttons. An example of the reimplementation is available here .- See also - 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 returns- false.- By explicitly calling - setFinalPage(true), you can let the user perform an “early finish”.- See also - nextId()¶
- Return type:
- int 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - 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: - def nextId(self): - See also - 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’t specify a pixmap.- See also - setPixmap()- pixmap()- Elements of a Wizard Page- registerField(name, widget, property, changedSignal)¶
- Parameters:
- name – str 
- widget – - QWidget
- property – str 
- changedSignal – - PySideSignalInstance
 
 
 - registerField(name, widget[, property=None[, changedSignal=None]])
- Parameters:
- name – str 
- widget – - QWidget
- property – str 
- changedSignal – str 
 
 
 - Creates a field called - nameassociated with the given- propertyof 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 - 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 a- changedSignalto be specified, to tell- QWizardto recheck the value stored by the mandatory field.- QWizardknows the most common Qt widgets. For these (or their subclasses), you don’t need to specify a- propertyor a- changedSignal. The table below lists these widgets:- Widget - Property - Change Notification Signal - bool - checked- int - value- int - currentIndex- QDateTime - dateTime- QString - text- int - currentRow- int - value- You can use - setDefaultProperty()to add entries to this table or to override existing entries.- To consider a field “filled”, - QWizardsimply 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.- QWizard‘s mandatory field mechanism is provided for convenience. It can be bypassed by reimplementing- isComplete().- See also - setButtonText(which, text)¶
- Parameters:
- which – - WizardButton
- text – str 
 
 
 - Sets the text on button - whichto be- texton this page.- By default, the text on buttons depends on the - wizardStyle, but may be redefined for the wizard as a whole using- setButtonText().- See also - 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 - setField(name, value)¶
- Parameters:
- name – str 
- value – object 
 
 
 - Sets the value of the field called - nameto- value.- This function can be used to set fields on any page of the wizard. It is equivalent to calling - wizard()->``name`` :meth:` <PySide6.QtWidgets.QWizard.setField>` ,- value).- See also - setFinalPage(finalPage)¶
- Parameters:
- finalPage – bool 
 
 - Explicitly sets this page to be final if - finalPageis true.- After calling setFinalPage(true), - isFinalPage()returns- trueand the Finish button is visible (and enabled if- isComplete()returns true).- After calling setFinalPage(false), - isFinalPage()returns- trueif- nextId()returns -1; otherwise, it returns- false.- setPixmap(which, pixmap)¶
- Parameters:
- which – - WizardPixmap
- pixmap – - QPixmap
 
 
 - Sets the pixmap for role - whichto- pixmap.- The pixmaps are used by - QWizardwhen displaying a page. Which pixmaps are actually used depend on the- wizard style.- Pixmaps can also be set for the entire wizard using - setPixmap(), in which case they apply for all pages that don’t specify a pixmap.- See also - pixmap()- setPixmap()- Elements of a Wizard Page- setSubTitle(subTitle)¶
- Parameters:
- subTitle – str 
 - See also 
 - Setter of property - subTitleᅟ.- Setter of property - titleᅟ.- subTitle()¶
- Return type:
- str 
 - See also 
 - Getter of property - subTitleᅟ.- title()¶
- Return type:
- str 
 - See also 
 - Getter of property - titleᅟ.- 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 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 fieldsor reimplementing- isComplete()) than to reimplement validatePage().- See also - Returns the wizard associated with this page, or - Noneif this page hasn’t been inserted into a- QWizardyet.