File: AddDialog.pm

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 (65 lines) | stat: -rw-r--r-- 1,680 bytes parent folder | download
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
package AddDialog;

use strict;
use warnings;
use blib;

use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::Dialog );

sub NEW {
    my ( $class, $parent ) = @_;
    $class->SUPER::NEW( $parent );

    my $nameLabel = Qt::Label("Name");
    my $addressLabel = Qt::Label("Address");
    my $okButton = Qt::PushButton("OK");
    my $cancelButton = Qt::PushButton("Cancel");
    
    my $nameText = Qt::LineEdit();
    my $addressText = Qt::TextEdit();

    this->{nameLabel}    = $nameLabel;
    this->{addressLabel} = $addressLabel;
    this->{okButton}     = $okButton;
    this->{cancelButton} = $cancelButton;
    this->{nameText}     = $nameText;
    this->{addressText}  = $addressText;
    
    my $gLayout = Qt::GridLayout();
    $gLayout->setColumnStretch(1, 2);
    $gLayout->addWidget($nameLabel, 0, 0);
    $gLayout->addWidget($nameText, 0, 1);
    
    $gLayout->addWidget($addressLabel, 1, 0, Qt::AlignLeft()|Qt::AlignTop());
    $gLayout->addWidget($addressText, 1, 1, Qt::AlignLeft());
    
    my $buttonLayout = Qt::HBoxLayout();
    $buttonLayout->addWidget($okButton);
    $buttonLayout->addWidget($cancelButton);
    
    $gLayout->addLayout($buttonLayout, 2, 1, Qt::AlignRight());
    
    my $mainLayout = Qt::VBoxLayout();
    $mainLayout->addLayout($gLayout);
    this->setLayout($mainLayout);
    
    this->connect($okButton, SIGNAL 'clicked()',
            this, SLOT 'accept()');
            
    this->connect($cancelButton, SIGNAL 'clicked()',
            this, SLOT 'reject()');
            
    this->setWindowTitle(this->tr('Add a Contact'));
}

sub nameText {
    return this->{nameText};
}

sub addressText {
    return this->{addressText};
}

1;