summaryrefslogtreecommitdiffstats
path: root/examples/dialogs/trivialwizard/trivialwizard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dialogs/trivialwizard/trivialwizard.cpp')
-rw-r--r--examples/dialogs/trivialwizard/trivialwizard.cpp136
1 files changed, 136 insertions, 0 deletions
diff --git a/examples/dialogs/trivialwizard/trivialwizard.cpp b/examples/dialogs/trivialwizard/trivialwizard.cpp
new file mode 100644
index 0000000000..128bce76cd
--- /dev/null
+++ b/examples/dialogs/trivialwizard/trivialwizard.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QTranslator>
+#include <QLocale>
+#include <QLibraryInfo>
+
+//! [0] //! [1]
+QWizardPage *createIntroPage()
+{
+ QWizardPage *page = new QWizardPage;
+ page->setTitle("Introduction");
+
+ QLabel *label = new QLabel("This wizard will help you register your copy "
+ "of Super Product Two.");
+ label->setWordWrap(true);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(label);
+ page->setLayout(layout);
+
+ return page;
+}
+//! [0]
+
+//! [2]
+QWizardPage *createRegistrationPage()
+//! [1] //! [3]
+{
+//! [3]
+ QWizardPage *page = new QWizardPage;
+ page->setTitle("Registration");
+ page->setSubTitle("Please fill both fields.");
+
+ QLabel *nameLabel = new QLabel("Name:");
+ QLineEdit *nameLineEdit = new QLineEdit;
+
+ QLabel *emailLabel = new QLabel("Email address:");
+ QLineEdit *emailLineEdit = new QLineEdit;
+
+ QGridLayout *layout = new QGridLayout;
+ 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;
+//! [4]
+}
+//! [2] //! [4]
+
+//! [5] //! [6]
+QWizardPage *createConclusionPage()
+//! [5] //! [7]
+{
+//! [7]
+ QWizardPage *page = new QWizardPage;
+ page->setTitle("Conclusion");
+
+ QLabel *label = new QLabel("You are now successfully registered. Have a "
+ "nice day!");
+ label->setWordWrap(true);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(label);
+ page->setLayout(layout);
+
+ return page;
+//! [8]
+}
+//! [6] //! [8]
+
+//! [9] //! [10]
+int main(int argc, char *argv[])
+//! [9] //! [11]
+{
+ QApplication app(argc, argv);
+
+ QString translatorFileName = QLatin1String("qt_");
+ translatorFileName += QLocale::system().name();
+ QTranslator *translator = new QTranslator(&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");
+ wizard.show();
+
+ return app.exec();
+}
+//! [10] //! [11]