![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
#include <QtGui>
//介绍页 ![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QWizardPage *createIntroPage()
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
{
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QWizardPage *page =
new QWizardPage;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
page->setTitle(QObject::trUtf8(
"介绍"));
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QLabel *label =
new QLabel(QObject::trUtf8(
"该向导将辅助你完成此产品"
"的注册."));
//label->setWordWrap(true);
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QVBoxLayout *layout =
new QVBoxLayout;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
layout->addWidget(label);
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
page->setLayout(layout);
return page;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
}
//创建注册页 ![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QWizardPage *createRegistrationPage()
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
{
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QWizardPage *page =
new QWizardPage;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
page->setTitle(QObject::trUtf8(
"注册"));
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
page->setSubTitle(QObject::trUtf8(
"请填写全部两项:"));
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QLabel *nameLabel =
new QLabel(QObject::trUtf8(
"姓名:"));
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QLineEdit *nameLineEdit =
new QLineEdit;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QLabel *emailLabel =
new QLabel(QObject::trUtf8(
"电子邮箱:"));
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QLineEdit *emailLineEdit =
new QLineEdit;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QGridLayout *layout =
new QGridLayout;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
layout->addWidget(nameLabel, 0, 0);
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
layout->addWidget(nameLineEdit, 0, 1);
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
layout->addWidget(emailLabel, 1, 0);
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
layout->addWidget(emailLineEdit, 1, 1);
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
page->setLayout(layout);
return page;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
}
//创建结束页 ![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QWizardPage *createConclusionPage()
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
{
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QWizardPage *page =
new QWizardPage;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
page->setTitle(QObject::trUtf8(
"结束语"));
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QLabel *label =
new QLabel(QObject::trUtf8(
"你已经成功注册."
"祝您心情愉快!"));
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
label->setWordWrap(
true);
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QVBoxLayout *layout =
new QVBoxLayout;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
layout->addWidget(label);
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
page->setLayout(layout);
return page;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
}
int main(
int argc,
char *argv[])
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
{
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QApplication app(argc, argv);
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
QWizard wizard;
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
wizard.addPage(createIntroPage());
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
wizard.addPage(createRegistrationPage());
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
wizard.addPage(createConclusionPage());
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
wizard.setWindowTitle(QObject::trUtf8(
"软件注册向导"));
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
wizard.show();
return app.exec();
![Qt4--向导页_C++](https://s2.51cto.com/images/editer/InBlock.gif)
}