Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QWizard Class

TheQWizard class provides a framework for wizards.More...

Header:#include <QWizard>
Since: Qt 4.3
Inherits:QDialog

Public Types

enumWizardButton { BackButton, NextButton, CommitButton, FinishButton, ..., Stretch }
enumWizardOption { IndependentPages, IgnoreSubTitles, ExtendedWatermarkPixmap, NoDefaultButton, ..., HaveCustomButton3 }
flagsWizardOptions
enumWizardPixmap { WatermarkPixmap, LogoPixmap, BannerPixmap, BackgroundPixmap }
enumWizardStyle { ClassicStyle, ModernStyle, MacStyle, AeroStyle }

Properties

Public Functions

QWizard(QWidget * parent = 0, Qt::WindowFlags flags = 0)
~QWizard()
intaddPage(QWizardPage * page)
QAbstractButton *button(WizardButton which) const
QStringbuttonText(WizardButton which) const
intcurrentId() const
QWizardPage *currentPage() const
QVariantfield(const QString & name) const
boolhasVisitedPage(int id) const
virtual intnextId() const
WizardOptionsoptions() const
QWizardPage *page(int id) const
QList<int>pageIds() const
QPixmappixmap(WizardPixmap which) const
voidremovePage(int id)
voidsetButton(WizardButton which, QAbstractButton * button)
voidsetButtonLayout(const QList<WizardButton> & layout)
voidsetButtonText(WizardButton which, const QString & text)
voidsetDefaultProperty(const char * className, const char * property, const char * changedSignal)
voidsetField(const QString & name, const QVariant & value)
voidsetOption(WizardOption option, bool on = true)
voidsetOptions(WizardOptions options)
voidsetPage(int id, QWizardPage * page)
voidsetPixmap(WizardPixmap which, const QPixmap & pixmap)
voidsetSideWidget(QWidget * widget)
voidsetStartId(int id)
voidsetSubTitleFormat(Qt::TextFormat format)
voidsetTitleFormat(Qt::TextFormat format)
voidsetWizardStyle(WizardStyle style)
QWidget *sideWidget() const
intstartId() const
Qt::TextFormatsubTitleFormat() const
booltestOption(WizardOption option) const
Qt::TextFormattitleFormat() const
virtual boolvalidateCurrentPage()
QList<int>visitedPages() const
WizardStylewizardStyle() const

Reimplemented Public Functions

virtual voidsetVisible(bool visible)
virtual QSizesizeHint() const
  • 8 public functions inherited fromQDialog
  • 220 public functions inherited fromQWidget
  • 29 public functions inherited fromQObject
  • 12 public functions inherited fromQPaintDevice

Public Slots

voidback()
voidnext()
voidrestart()
  • 5 public slots inherited fromQDialog
  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject

Signals

voidcurrentIdChanged(int id)
voidcustomButtonClicked(int which)
voidhelpRequested()
voidpageAdded(int id)
voidpageRemoved(int id)

Protected Functions

virtual voidcleanupPage(int id)
virtual voidinitializePage(int id)

Reimplemented Protected Functions

virtual voiddone(int result)
virtual boolevent(QEvent * event)
virtual voidpaintEvent(QPaintEvent * event)
virtual voidresizeEvent(QResizeEvent * event)
virtual boolwinEvent(MSG * message, long * result)
  • 7 protected functions inherited fromQDialog
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 1 protected slot inherited fromQWidget

Detailed Description

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:

A Trivial Example

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();}

Wizard Look and Feel

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()));

Elements of a Wizard Page

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().

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., 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 &macro"));    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.

Creating Linear Wizards

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.

Creating Non-Linear Wizards

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.

Member Type Documentation

enum QWizard::WizardButton

This enum specifies the buttons in a wizard.

ConstantValueDescription
QWizard::BackButton0TheBack button (Go Back on Mac OS X)
QWizard::NextButton1TheNext button (Continue on Mac OS X)
QWizard::CommitButton2TheCommit button
QWizard::FinishButton3TheFinish button (Done on Mac OS X)
QWizard::CancelButton4TheCancel button (see alsoNoCancelButton)
QWizard::HelpButton5TheHelp button (see alsoHaveHelpButton)
QWizard::CustomButton16The first user-defined button (see alsoHaveCustomButton1)
QWizard::CustomButton27The second user-defined button (see alsoHaveCustomButton2)
QWizard::CustomButton38The third user-defined button (see alsoHaveCustomButton3)

The following value is only useful when callingsetButtonLayout():

ConstantValueDescription
QWizard::Stretch9A horizontal stretch in the button layout

See alsosetButton(),setButtonText(),setButtonLayout(), andcustomButtonClicked().

enum QWizard::WizardOption
flags QWizard::WizardOptions

This enum specifies various options that affect the look and feel of a wizard.

ConstantValueDescription
QWizard::IndependentPages0x00000001The pages are independent of each other (i.e., they don't derive values from each other).
QWizard::IgnoreSubTitles0x00000002Don't show any subtitles, even if they are set.
QWizard::ExtendedWatermarkPixmap0x00000004Extend anyWatermarkPixmap all the way down to the window's edge.
QWizard::NoDefaultButton0x00000008Don't make theNext orFinish button the dialog'sdefault button.
QWizard::NoBackButtonOnStartPage0x00000010Don't show theBack button on the start page.
QWizard::NoBackButtonOnLastPage0x00000020Don't show theBack button on the last page.
QWizard::DisabledBackButtonOnLastPage0x00000040Disable theBack button on the last page.
QWizard::HaveNextButtonOnLastPage0x00000080Show the (disabled)Next button on the last page.
QWizard::HaveFinishButtonOnEarlyPages0x00000100Show the (disabled)Finish button on non-final pages.
QWizard::NoCancelButton0x00000200Don't show theCancel button.
QWizard::CancelButtonOnLeft0x00000400Put theCancel button on the left ofBack (rather than on the right ofFinish orNext).
QWizard::HaveHelpButton0x00000800Show theHelp button.
QWizard::HelpButtonOnRight0x00001000Put theHelp button on the far right of the button layout (rather than on the far left).
QWizard::HaveCustomButton10x00002000Show the first user-defined button (CustomButton1).
QWizard::HaveCustomButton20x00004000Show the second user-defined button (CustomButton2).
QWizard::HaveCustomButton30x00008000Show 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().

enum QWizard::WizardPixmap

This enum specifies the pixmaps that can be associated with a page.

ConstantValueDescription
QWizard::WatermarkPixmap0The tall pixmap on the left side of aClassicStyle orModernStyle page
QWizard::LogoPixmap1The small pixmap on the right side of aClassicStyle orModernStyle page header
QWizard::BannerPixmap2The pixmap that occupies the background of aModernStyle page header
QWizard::BackgroundPixmap3The pixmap that occupies the background of aMacStyle wizard

See alsosetPixmap(),QWizardPage::setPixmap(), andElements of a Wizard Page.

enum QWizard::WizardStyle

This enum specifies the different looks supported byQWizard.

ConstantValueDescription
QWizard::ClassicStyle0Classic Windows look
QWizard::ModernStyle1Modern Windows look
QWizard::MacStyle2Mac OS X look
QWizard::AeroStyle3Windows Aero look

See alsosetWizardStyle(),WizardOption, andWizard Look and Feel.

Property Documentation

currentId : constint

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:

intcurrentId() const

Notifier signal:

voidcurrentIdChanged(int id)

See alsocurrentIdChanged() andcurrentPage().

options :WizardOptions

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:

WizardOptionsoptions() const
voidsetOptions(WizardOptions options)

See alsowizardStyle.

startId :int

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:

intstartId() const
voidsetStartId(int id)

See alsorestart() andnextId().

subTitleFormat :Qt::TextFormat

This property holds the text format used by page subtitles.

The default format isQt::AutoText.

Access functions:

Qt::TextFormatsubTitleFormat() const
voidsetSubTitleFormat(Qt::TextFormat format)

See alsoQWizardPage::title andtitleFormat.

titleFormat :Qt::TextFormat

This property holds the text format used by page titles.

The default format isQt::AutoText.

Access functions:

Qt::TextFormattitleFormat() const
voidsetTitleFormat(Qt::TextFormat format)

See alsoQWizardPage::title andsubTitleFormat.

wizardStyle :WizardStyle

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:

WizardStylewizardStyle() const
voidsetWizardStyle(WizardStyle style)

See alsoWizard Look and Feel andoptions.

Member Function Documentation

QWizard::QWizard(QWidget * parent = 0,Qt::WindowFlags flags = 0)

Constructs a wizard with the givenparent and windowflags.

See alsoparent() andwindowFlags().

QWizard::~QWizard()

Destroys the wizard and its pages, releasing any allocated resources.

int QWizard::addPage(QWizardPage * page)

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().

QAbstractButton * QWizard::button(WizardButton which) const

Returns the button corresponding to rolewhich.

See alsosetButton() andsetButtonText().

QString QWizard::buttonText(WizardButton which) const

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().

QWizardPage * QWizard::currentPage() const

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().

QVariant QWizard::field(constQString & name) const

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().

bool QWizard::hasVisitedPage(int id) const

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() const

This 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().

QWizardPage * QWizard::page(int id) const

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().

QList<int> QWizard::pageIds() const

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().

QPixmap QWizard::pixmap(WizardPixmap which) const

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.

void QWizard::removePage(int id)

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().

void QWizard::setButton(WizardButton which,QAbstractButton * button)

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.

void QWizard::setButtonLayout(constQList<WizardButton> & layout)

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().

void QWizard::setButtonText(WizardButton which, constQString & text)

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().

void QWizard::setDefaultProperty(constchar * className, constchar * property, constchar * changedSignal)

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().

void QWizard::setField(constQString & name, constQVariant & value)

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().

void QWizard::setOption(WizardOption option,bool on = true)

Sets the givenoption to be enabled ifon is true; otherwise, clears the givenoption.

See alsooptions,testOption(), andsetWizardStyle().

void QWizard::setPage(int id,QWizardPage * page)

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().

void QWizard::setPixmap(WizardPixmap which, constQPixmap & pixmap)

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.

void QWizard::setSideWidget(QWidget * widget)

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().

QWidget * QWizard::sideWidget() const

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() const

Reimplemented fromQWidget::sizeHint().

bool QWizard::testOption(WizardOption option) const

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().

QList<int> QWizard::visitedPages() const

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.


[8]ページ先頭

©2009-2025 Movatter.jp