QWizardPage

Inheritance diagram of PySide2.QtWidgets.QWizardPage

Synopsis

Functions

Virtual functions

Signals

Detailed Description

The PySide2.QtWidgets.QWizardPage class is the base class for wizard pages.

PySide2.QtWidgets.QWizard represents a wizard. Each page is a PySide2.QtWidgets.QWizardPage . When you create your own wizards, you can use PySide2.QtWidgets.QWizardPage directly, or you can subclass it for more control.

A page has the following attributes, which are rendered by PySide2.QtWidgets.QWizard : a PySide2.QtWidgets.QWizardPage.title() , a PySide2.QtWidgets.QWizardPage.subTitle() , and a set of pixmaps . See Elements of a Wizard Page for details. Once a page is added to the wizard (using QWizard.addPage() or QWizard.setPage() ), PySide2.QtWidgets.QWizardPage.wizard() returns a pointer to the associated PySide2.QtWidgets.QWizard object.

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

Normally, the Next button and the Finish button of a wizard are mutually exclusive. If PySide2.QtWidgets.QWizardPage.isFinalPage() returns true , Finish is available; otherwise, Next is available. By default, PySide2.QtWidgets.QWizardPage.isFinalPage() is true only when PySide2.QtWidgets.QWizardPage.nextId() returns -1. If you want to show Next and Final simultaneously for a page (letting the user perform an “early finish”), call PySide2.QtWidgets.QWizardPage.setFinalPage() (true) on that page. For wizards that support early finishes, you might also want to set the HaveNextButtonOnLastPage and HaveFinishButtonOnEarlyPages options on the wizard.

In many wizards, the contents of a page may affect the default values of the fields of a later page. To make it easy to communicate between pages, PySide2.QtWidgets.QWizard supports a "field" mechanism that allows you to register a field (e.g., a PySide2.QtWidgets.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 PySide2.QtWidgets.QWizard or having the pages know explicitly about each other. Fields are registered using PySide2.QtWidgets.QWizardPage.registerField() and can be accessed at any time using PySide2.QtWidgets.QWizardPage.field() and PySide2.QtWidgets.QWizardPage.setField() .

class PySide2.QtWidgets.QWizardPage([parent=nullptr])
Parameters:parentPySide2.QtWidgets.QWidget

Constructs a wizard page with the given parent .

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

PySide2.QtWidgets.QWizardPage.buttonText(which)
Parameters:whichPySide2.QtWidgets.QWizard.WizardButton
Return type:unicode

Returns the text on button which on this page.

If a text has ben set using PySide2.QtWidgets.QWizardPage.setButtonText() , this text is returned. Otherwise, if a text has been set using QWizard.setButtonText() , this text is returned.

By default, the text on buttons depends on the QWizard.wizardStyle . For example, on macOS , the Next button is called Continue.

PySide2.QtWidgets.QWizardPage.cleanupPage()

This virtual function is called by QWizard.cleanupPage() when the user leaves the page by clicking Back (unless the QWizard.IndependentPages option is set).

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

PySide2.QtWidgets.QWizardPage.completeChanged()
PySide2.QtWidgets.QWizardPage.field(name)
Parameters:name – unicode
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 PySide2.QtWidgets.QWizardPage.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()))
PySide2.QtWidgets.QWizardPage.initializePage()

This virtual function is called by QWizard.initializePage() to prepare the page 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. 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.

PySide2.QtWidgets.QWizardPage.isCommitPage()
Return type:PySide2.QtCore.bool

Returns true if this page is a commit page; otherwise returns false .

PySide2.QtWidgets.QWizardPage.isComplete()
Return type:PySide2.QtCore.bool

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

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

If you reimplement this function, make sure to emit PySide2.QtWidgets.QWizardPage.completeChanged() , from the rest of your implementation, whenever the value of changes. This ensures that PySide2.QtWidgets.QWizard updates the enabled or disabled state of its buttons. An example of the reimplementation is available here.

PySide2.QtWidgets.QWizardPage.isFinalPage()
Return type:PySide2.QtCore.bool

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

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

By explicitly calling PySide2.QtWidgets.QWizardPage.setFinalPage() (true), you can let the user perform an “early finish”.

See also

PySide2.QtWidgets.QWizardPage.isComplete() QWizard.HaveFinishButtonOnEarlyPages

PySide2.QtWidgets.QWizardPage.nextId()
Return type:PySide2.QtCore.int

This virtual function is called by QWizard.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:

# class IntroPage
def nextId(self):

    if evaluateRadioButton.isChecked():
        return LicenseWizard.Page_Evaluate
    else:
        return LicenseWizard.Page_Register

See also

QWizard.nextId()

PySide2.QtWidgets.QWizardPage.pixmap(which)
Parameters:whichPySide2.QtWidgets.QWizard.WizardPixmap
Return type:PySide2.QtGui.QPixmap

Returns the pixmap set for role which .

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

See also

PySide2.QtWidgets.QWizardPage.setPixmap() QWizard.pixmap() Elements of a Wizard Page

PySide2.QtWidgets.QWizardPage.registerField(name, widget[, property=nullptr[, changedSignal=nullptr]])
Parameters:

Creates a field called name associated with the given property of the given widget . From then on, that property becomes accessible using PySide2.QtWidgets.QWizardPage.field() and PySide2.QtWidgets.QWizardPage.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 PySide2.QtWidgets.QWizard or having the pages know explicitly about each other.

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

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

Widget Property Change Notification Signal
PySide2.QtWidgets.QAbstractButton bool PySide2.QtWidgets.QAbstractButton.checked() PySide2.QtWidgets.QAbstractButton.toggled()
PySide2.QtWidgets.QAbstractSlider int PySide2.QtWidgets.QAbstractSlider.value() PySide2.QtWidgets.QAbstractSlider.valueChanged()
PySide2.QtWidgets.QComboBox int PySide2.QtWidgets.QComboBox.currentIndex() PySide2.QtWidgets.QComboBox.currentIndexChanged()
PySide2.QtWidgets.QDateTimeEdit PySide2.QtCore.QDateTime PySide2.QtWidgets.QDateTimeEdit.dateTime() PySide2.QtWidgets.QDateTimeEdit.dateTimeChanged()
PySide2.QtWidgets.QLineEdit PySide2.QtCore.QString PySide2.QtWidgets.QLineEdit.text() PySide2.QtWidgets.QLineEdit.textChanged()
PySide2.QtWidgets.QListWidget int PySide2.QtWidgets.QListWidget.currentRow() PySide2.QtWidgets.QListWidget.currentRowChanged()
PySide2.QtWidgets.QSpinBox int PySide2.QtWidgets.QSpinBox.value() PySide2.QtWidgets.QSpinBox.valueChanged()

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

To consider a field “filled”, PySide2.QtWidgets.QWizard simply checks that their current value doesn’t equal their original value (the value they had before PySide2.QtWidgets.QWizardPage.initializePage() was called). For PySide2.QtWidgets.QLineEdit , it also checks that PySide2.QtWidgets.QLineEdit.hasAcceptableInput() returns true, to honor any validator or mask.

PySide2.QtWidgets.QWizard ‘s mandatory field mechanism is provided for convenience. It can be bypassed by reimplementing QWizardPage.isComplete() .

PySide2.QtWidgets.QWizardPage.setButtonText(which, text)
Parameters:

Sets the text on button which to be text on this page.

By default, the text on buttons depends on the QWizard.wizardStyle , but may be redefined for the wizard as a whole using QWizard.setButtonText() .

PySide2.QtWidgets.QWizardPage.setCommitPage(commitPage)
Parameters:commitPagePySide2.QtCore.bool

Sets this page to be a commit page if commitPage is 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 QWizard.next() just like clicking Next does.

A page entered directly from a commit page has its Back button disabled.

PySide2.QtWidgets.QWizardPage.setField(name, value)
Parameters:
  • name – unicode
  • value – object

Sets the value of the field called name to value .

This function can be used to set fields on any page of the wizard. It is equivalent to calling PySide2.QtWidgets.QWizardPage.wizard() ->``name`` :meth:` <PySide2.QtWidgets.QWizard.setField>` , value ).

PySide2.QtWidgets.QWizardPage.setFinalPage(finalPage)
Parameters:finalPagePySide2.QtCore.bool

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

After calling (true), PySide2.QtWidgets.QWizardPage.isFinalPage() returns true and the Finish button is visible (and enabled if PySide2.QtWidgets.QWizardPage.isComplete() returns true).

After calling (false), PySide2.QtWidgets.QWizardPage.isFinalPage() returns true if PySide2.QtWidgets.QWizardPage.nextId() returns -1; otherwise, it returns false .

PySide2.QtWidgets.QWizardPage.setPixmap(which, pixmap)
Parameters:

Sets the pixmap for role which to pixmap .

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

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

See also

PySide2.QtWidgets.QWizardPage.pixmap() QWizard.setPixmap() Elements of a Wizard Page

PySide2.QtWidgets.QWizardPage.setSubTitle(subTitle)
Parameters:subTitle – unicode
PySide2.QtWidgets.QWizardPage.setTitle(title)
Parameters:title – unicode
PySide2.QtWidgets.QWizardPage.subTitle()
Return type:unicode
PySide2.QtWidgets.QWizardPage.title()
Return type:unicode
PySide2.QtWidgets.QWizardPage.validatePage()
Return type:PySide2.QtCore.bool

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

The default implementation returns true .

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

PySide2.QtWidgets.QWizardPage.wizard()
Return type:PySide2.QtWidgets.QWizard

Returns the wizard associated with this page, or 0 if this page hasn’t been inserted into a PySide2.QtWidgets.QWizard yet.