trivialwizard.cpp Example File | Qt 4.8 (original) (raw)

dialogs/trivialwizard/trivialwizard.cpp

#include #include #include #include

QWizardPage *createIntroPage() { QWizardPage *page = new QWizardPage; page->setTitle("Introduction");

[QLabel](qlabel.html) *label = new [QLabel](qlabel.html)("This wizard will help you register your copy "
                           "of Super Product Two.");
label->setWordWrap(true);

[QVBoxLayout](qvboxlayout.html) *layout = new [QVBoxLayout](qvboxlayout.html);
layout->addWidget(label);
page->setLayout(layout);

return page;

}

QWizardPage *createRegistrationPage() { QWizardPage *page = new QWizardPage; page->setTitle("Registration"); page->setSubTitle("Please fill both fields.");

[QLabel](qlabel.html) *nameLabel = new [QLabel](qlabel.html)("Name:");
[QLineEdit](qlineedit.html) *nameLineEdit = new [QLineEdit](qlineedit.html);

[QLabel](qlabel.html) *emailLabel = new [QLabel](qlabel.html)("Email address:");
[QLineEdit](qlineedit.html) *emailLineEdit = new [QLineEdit](qlineedit.html);

[QGridLayout](qgridlayout.html) *layout = new [QGridLayout](qgridlayout.html);
layout->addWidget(nameLabel, 0, 0);
layout->addWidget(nameLineEdit, 0, 1);
layout->addWidget(emailLabel, 1, 0);
layout->addWidget(emailLineEdit, 1, 1);
page->setLayout(layout);

return page;

}

QWizardPage *createConclusionPage() { QWizardPage *page = new QWizardPage; page->setTitle("Conclusion");

[QLabel](qlabel.html) *label = new [QLabel](qlabel.html)("You are now successfully registered. Have a "
                           "nice day!");
label->setWordWrap(true);

[QVBoxLayout](qvboxlayout.html) *layout = new [QVBoxLayout](qvboxlayout.html);
layout->addWidget(label);
page->setLayout(layout);

return page;

}

int main(int argc, char *argv[]) { QApplication app(argc, argv);

[QString](qstring.html) translatorFileName = QLatin1String("qt_");
translatorFileName += [QLocale](qlocale.html)::system().name();
[QTranslator](qtranslator.html) *translator = new [QTranslator](qtranslator.html)(&app);
if (translator->load(translatorFileName, [QLibraryInfo](qlibraryinfo.html)::location([QLibraryInfo](qlibraryinfo.html)::TranslationsPath)))
    app.installTranslator(translator);

[QWizard](qwizard.html) wizard;
wizard.addPage(createIntroPage());
wizard.addPage(createRegistrationPage());
wizard.addPage(createConclusionPage());

wizard.setWindowTitle("Trivial Wizard");

#ifdef Q_OS_SYMBIAN wizard.showMaximized(); #else wizard.show(); #endif

return app.exec();

}

© 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 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.