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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
|
package Window;
use strict;
use warnings;
use blib;
use QtCore4;
use QtGui4;
# [0]
use QtCore4::isa qw( Qt::Widget );
use QtCore4::slots
echoChanged => ['int'],
validatorChanged => ['int'],
alignmentChanged => ['int'],
inputMaskChanged => ['int'],
accessChanged => ['int'];
sub echoLineEdit() {
return this->{echoLineEdit};
}
sub setEchoLineEdit() {
return this->{echoLineEdit} = shift;
}
sub validatorLineEdit() {
return this->{validatorLineEdit};
}
sub setValidatorLineEdit() {
return this->{validatorLineEdit} = shift;
}
sub alignmentLineEdit() {
return this->{alignmentLineEdit};
}
sub setAlignmentLineEdit() {
return this->{alignmentLineEdit} = shift;
}
sub inputMaskLineEdit() {
return this->{inputMaskLineEdit};
}
sub setInputMaskLineEdit() {
return this->{inputMaskLineEdit} = shift;
}
sub accessLineEdit() {
return this->{accessLineEdit};
}
sub setAccessLineEdit() {
return this->{accessLineEdit} = shift;
}
# [0]
# [0]
sub NEW {
my ( $class, $parent ) = @_;
$class->SUPER::NEW( $parent );
my $echoGroup = Qt::GroupBox(this->tr('Echo'));
my $echoLabel = Qt::Label(this->tr('Mode:'));
my $echoComboBox = Qt::ComboBox();
$echoComboBox->addItem(this->tr('Normal'));
$echoComboBox->addItem(this->tr('Password'));
$echoComboBox->addItem(this->tr('PasswordEchoOnEdit'));
$echoComboBox->addItem(this->tr('No Echo'));
this->setEchoLineEdit( Qt::LineEdit() );
this->echoLineEdit->setFocus();
# [0]
# [1]
my $validatorGroup = Qt::GroupBox(this->tr('Validator'));
my $validatorLabel = Qt::Label(this->tr('Type:'));
my $validatorComboBox = Qt::ComboBox();
$validatorComboBox->addItem(this->tr('No validator'));
$validatorComboBox->addItem(this->tr('Integer validator'));
$validatorComboBox->addItem(this->tr('Double validator'));
this->setValidatorLineEdit( Qt::LineEdit() );
# [1]
# [2]
my $alignmentGroup = Qt::GroupBox(this->tr('Alignment'));
my $alignmentLabel = Qt::Label(this->tr('Type:'));
my $alignmentComboBox = Qt::ComboBox();
$alignmentComboBox->addItem(this->tr('Left'));
$alignmentComboBox->addItem(this->tr('Centered'));
$alignmentComboBox->addItem(this->tr('Right'));
this->setAlignmentLineEdit( Qt::LineEdit() );
# [2]
# [3]
my $inputMaskGroup = Qt::GroupBox(this->tr('Input mask'));
my $inputMaskLabel = Qt::Label(this->tr('Type:'));
my $inputMaskComboBox = Qt::ComboBox();
$inputMaskComboBox->addItem(this->tr('No mask'));
$inputMaskComboBox->addItem(this->tr('Phone number'));
$inputMaskComboBox->addItem(this->tr('ISO date'));
$inputMaskComboBox->addItem(this->tr('License key'));
this->setInputMaskLineEdit( Qt::LineEdit() );
# [3]
# [4]
my $accessGroup = Qt::GroupBox(this->tr('Access'));
my $accessLabel = Qt::Label(this->tr('Read-only:'));
my $accessComboBox = Qt::ComboBox();
$accessComboBox->addItem(this->tr('False'));
$accessComboBox->addItem(this->tr('True'));
this->setAccessLineEdit( Qt::LineEdit() );
# [4]
# [5]
this->connect($echoComboBox, SIGNAL 'activated(int)',
this, SLOT 'echoChanged(int)');
this->connect($validatorComboBox, SIGNAL 'activated(int)',
this, SLOT 'validatorChanged(int)');
this->connect($alignmentComboBox, SIGNAL 'activated(int)',
this, SLOT 'alignmentChanged(int)');
this->connect($inputMaskComboBox, SIGNAL 'activated(int)',
this, SLOT 'inputMaskChanged(int)');
this->connect($accessComboBox, SIGNAL 'activated(int)',
this, SLOT 'accessChanged(int)');
# [5]
# [6]
my $echoLayout = Qt::GridLayout();
$echoLayout->addWidget($echoLabel, 0, 0);
$echoLayout->addWidget($echoComboBox, 0, 1);
$echoLayout->addWidget(this->echoLineEdit, 1, 0, 1, 2);
$echoGroup->setLayout($echoLayout);
# [6]
# [7]
my $validatorLayout = Qt::GridLayout();
$validatorLayout->addWidget($validatorLabel, 0, 0);
$validatorLayout->addWidget($validatorComboBox, 0, 1);
$validatorLayout->addWidget(this->validatorLineEdit, 1, 0, 1, 2);
$validatorGroup->setLayout($validatorLayout);
my $alignmentLayout = Qt::GridLayout();
$alignmentLayout->addWidget($alignmentLabel, 0, 0);
$alignmentLayout->addWidget($alignmentComboBox, 0, 1);
$alignmentLayout->addWidget(this->alignmentLineEdit, 1, 0, 1, 2);
$alignmentGroup->setLayout($alignmentLayout);
my $inputMaskLayout = Qt::GridLayout();
$inputMaskLayout->addWidget($inputMaskLabel, 0, 0);
$inputMaskLayout->addWidget($inputMaskComboBox, 0, 1);
$inputMaskLayout->addWidget(this->inputMaskLineEdit, 1, 0, 1, 2);
$inputMaskGroup->setLayout($inputMaskLayout);
my $accessLayout = Qt::GridLayout();
$accessLayout->addWidget($accessLabel, 0, 0);
$accessLayout->addWidget($accessComboBox, 0, 1);
$accessLayout->addWidget(this->accessLineEdit, 1, 0, 1, 2);
$accessGroup->setLayout($accessLayout);
# [7]
# [8]
my $layout = Qt::GridLayout();
$layout->addWidget($echoGroup, 0, 0);
$layout->addWidget($validatorGroup, 1, 0);
$layout->addWidget($alignmentGroup, 2, 0);
$layout->addWidget($inputMaskGroup, 0, 1);
$layout->addWidget($accessGroup, 1, 1);
this->setLayout($layout);
this->setWindowTitle(this->tr('Line Edits'));
}
# [8]
# [9]
sub echoChanged {
my ($index) = @_;
if ($index == 0) {
this->echoLineEdit->setEchoMode(Qt::LineEdit::Normal());
}
elsif ( $index == 1 ) {
this->echoLineEdit->setEchoMode(Qt::LineEdit::Password());
}
elsif ( $index == 2 ) {
this->echoLineEdit->setEchoMode(Qt::LineEdit::PasswordEchoOnEdit());
}
elsif ( $index == 3 ) {
this->echoLineEdit->setEchoMode(Qt::LineEdit::NoEcho());
}
}
# [9]
# [10]
sub validatorChanged {
my ($index) = @_;
if ( $index == 0 ) {
this->validatorLineEdit->setValidator(0);
}
elsif ( $index == 1 ) {
this->validatorLineEdit->setValidator(Qt::IntValidator(
this->validatorLineEdit));
}
elsif ( $index == 2 ) {
this->validatorLineEdit->setValidator(Qt::DoubleValidator(-999.0,
999.0, 2, this->validatorLineEdit));
}
this->validatorLineEdit->clear();
}
# [10]
# [11]
sub alignmentChanged {
my ($index) = @_;
if ( $index == 0 ) {
this->alignmentLineEdit->setAlignment(Qt::AlignLeft());
}
elsif ( $index == 1 ) {
this->alignmentLineEdit->setAlignment(Qt::AlignCenter());
}
elsif ( $index == 2 ) {
this->alignmentLineEdit->setAlignment(Qt::AlignRight());
}
}
# [11]
# [12]
sub inputMaskChanged {
my ($index) = @_;
if ( $index == 0 ) {
this->inputMaskLineEdit->setInputMask('');
}
elsif ( $index == 1 ) {
this->inputMaskLineEdit->setInputMask('+99 99 99 99 99;_');
}
elsif ( $index == 2 ) {
this->inputMaskLineEdit->setInputMask('0000-00-00');
this->inputMaskLineEdit->setText('00000000');
this->inputMaskLineEdit->setCursorPosition(0);
}
elsif ( $index == 3 ) {
this->inputMaskLineEdit->setInputMask('>AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#');
}
}
# [12]
# [13]
sub accessChanged {
my ($index) = @_;
if ( $index == 0 ) {
this->accessLineEdit->setReadOnly(0);
}
elsif ( $index == 1 ) {
this->accessLineEdit->setReadOnly(1);
}
}
# [13]
1;
|