#!/usr/bin/perl -w
package MyWidget;
use Qt 2.0;
import Qt::app;
@ISA = qw(Qt::Widget);
sub new {
my $self = shift->SUPER::new(@_);
my $value;
$self->setMinimumSize(200, 300);
my $quit = Qt::PushButton->new('Quit', $self, 'quit');
$quit->setGeometry(10, 10, 75, 30);
$quit->setFont(Qt::Font->new('Times', 18, Qt::Font::Bold));
$app->connect($quit, 'clicked()', 'quit()');
for my $x (0..15) {
$value->[$x] = LCDRange->new($self);
$value->[$x-1]->connect($value->[$x], 'valueChanged(int)',
'setValue(int)') if $x;
}
@$self{'quit', 'value'} = ($quit, $value);
return $self;
}
sub resizeEvent {
my $self = shift;
my($quit, $value) = @$self{'quit', 'value'};
my $startx = 10;
my $starty = $quit->y() + $quit->height() + 10;
my $valueWidth = ($self->width() - $startx - 10 - 3*5)/4;
my $valueHeight = ($self->height() - $starty - 10 - 3*5)/4;
for(0..15) {
$$value[$_]->setGeometry($startx + ($_%4)*(5+$valueWidth),
$starty + int($_/4)*(5+$valueHeight),
$valueWidth, $valueHeight);
}
}
package main;
use Qt 2.0;
import Qt::app;
$w = MyWidget->new;
$w->setGeometry(100, 100, 400, 400);
$app->setMainWidget($w);
$w->show();
exit $app->exec();