File: trivialwizard.pl

package info (click to toggle)
qt4-perl 4.5~~svn1145508-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,144 kB
  • ctags: 5,947
  • sloc: perl: 29,224; cpp: 18,849; xml: 98; makefile: 91; sh: 4
file content (96 lines) | stat: -rwxr-xr-x 2,189 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/perl

use strict;
use warnings;

use QtCore4;
use QtGui4;

# [0] //! [1]
sub createIntroPage {
    my $page = Qt::WizardPage();
    $page->setTitle('Introduction');

    my $label = Qt::Label('This wizard will help you register your copy ' .
                               'of Super Product Two.');
    $label->setWordWrap(1);

    my $layout = Qt::VBoxLayout();
    $layout->addWidget($label);
    $page->setLayout($layout);

    return $page;
}
# [0]

# [2]
sub createRegistrationPage {
# [1] //! [3]
# [3]
    my $page = Qt::WizardPage();
    $page->setTitle('Registration');
    $page->setSubTitle('Please fill both fields.');

    my $nameLabel = Qt::Label('Name:');
    my $nameLineEdit = Qt::LineEdit();

    my $emailLabel = Qt::Label('Email address:');
    my $emailLineEdit = Qt::LineEdit();

    my $layout = Qt::GridLayout();
    $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]
sub createConclusionPage {
# [5] //! [7]
# [7]
    my $page = Qt::WizardPage();
    $page->setTitle('Conclusion');

    my $label = Qt::Label('You are now successfully registered. Have a ' .
                               'nice day!');
    $label->setWordWrap(1);

    my $layout = Qt::VBoxLayout();
    $layout->addWidget($label);
    $page->setLayout($layout);

    return $page;
# [8]
}
# [6] //! [8]

# [9] //! [10]
sub main {
# [9] //! [11]
    my $app = Qt::Application( \@ARGV );

    my $translatorFileName = 'qt_';
    $translatorFileName .= Qt::Locale::system()->name();
    my $translator = Qt::Translator($app);
    if ($translator->load($translatorFileName, Qt::LibraryInfo::location(Qt::LibraryInfo::TranslationsPath()))) {
        $app->installTranslator($translator);
    }

    my $wizard = Qt::Wizard();
    $wizard->addPage(createIntroPage());
    $wizard->addPage(createRegistrationPage());
    $wizard->addPage(createConclusionPage());

    $wizard->setWindowTitle('Trivial Wizard');
    $wizard->show();

    exit $app->exec();
}
# [10] //! [11]

main();