diff options
Diffstat (limited to 'PerlQt/tutorials/t12')
-rw-r--r-- | PerlQt/tutorials/t12/CannonField.pm | 50 | ||||
-rw-r--r-- | PerlQt/tutorials/t12/LCDRange.pm | 20 | ||||
-rw-r--r-- | PerlQt/tutorials/t12/t12.pl | 36 |
3 files changed, 53 insertions, 53 deletions
diff --git a/PerlQt/tutorials/t12/CannonField.pm b/PerlQt/tutorials/t12/CannonField.pm index df4eb96..6cc1529 100644 --- a/PerlQt/tutorials/t12/CannonField.pm +++ b/PerlQt/tutorials/t12/CannonField.pm @@ -1,18 +1,18 @@ package CannonField; use strict; -use Qt; -use Qt::isa qw(Qt::Widget); -use Qt::signals +use TQt; +use TQt::isa qw(TQt::Widget); +use TQt::signals hit => [], missed => [], angleChanged => ['int'], forceChanged => ['int']; -use Qt::slots +use TQt::slots setAngle => ['int'], setForce => ['int'], shoot => [], moveShot => []; -use Qt::attributes qw( +use TQt::attributes qw( ang f @@ -34,12 +34,12 @@ sub NEW { ang = 45; f = 0; timerCount = 0; - autoShootTimer = Qt::Timer(this, "movement handler"); - this->connect(autoShootTimer, SIGNAL('timeout()'), SLOT('moveShot()')); + autoShootTimer = TQt::Timer(this, "movement handler"); + this->connect(autoShootTimer, TQT_SIGNAL('timeout()'), TQT_SLOT('moveShot()')); shoot_ang = 0; shoot_f = 0; - target = Qt::Point(0, 0); - setPalette(Qt::Palette(Qt::Color(250, 250, 200))); + target = TQt::Point(0, 0); + setPalette(TQt::Palette(TQt::Color(250, 250, 200))); newTarget(); } @@ -70,14 +70,14 @@ sub shoot { } sub newTarget { - my $r = Qt::Region(targetRect()); - target = Qt::Point(200 + int(rand(190)), + my $r = TQt::Region(targetRect()); + target = TQt::Point(200 + int(rand(190)), 10 + int(rand(255))); - repaint($r->unite(Qt::Region(targetRect()))); + repaint($r->unite(TQt::Region(targetRect()))); } sub moveShot { - my $r = Qt::Region(shotRect()); + my $r = TQt::Region(shotRect()); timerCount++; my $shotR = shotRect(); @@ -89,7 +89,7 @@ sub moveShot { autoShootTimer->stop; emit missed(); } else { - $r = $r->unite(Qt::Region($shotR)); + $r = $r->unite(TQt::Region($shotR)); } repaint($r); } @@ -97,7 +97,7 @@ sub moveShot { sub paintEvent { my $e = shift; my $updateR = $e->rect; - my $p = Qt::Painter(this); + my $p = TQt::Painter(this); paintCannon($p) if $updateR->intersects(cannonRect()); paintShot($p) if autoShootTimer->isActive and $updateR->intersects(shotRect()); @@ -118,20 +118,20 @@ sub paintTarget { $p->drawRect(targetRect()); } -my $barrelRect = Qt::Rect(33, -4, 15, 8); +my $barrelRect = TQt::Rect(33, -4, 15, 8); sub paintCannon { my $p = shift; my $cr = cannonRect(); - my $pix = Qt::Pixmap($cr->size); + my $pix = TQt::Pixmap($cr->size); $pix->fill(this, $cr->topLeft); - my $tmp = Qt::Painter($pix); + my $tmp = TQt::Painter($pix); $tmp->setBrush(&blue); $tmp->setPen(&NoPen); $tmp->translate(0, $pix->height - 1); - $tmp->drawPie(Qt::Rect(-35, -35, 70, 70), 0, 90*16); + $tmp->drawPie(TQt::Rect(-35, -35, 70, 70), 0, 90*16); $tmp->rotate(- ang); $tmp->drawRect($barrelRect); $tmp->end; @@ -140,7 +140,7 @@ sub paintCannon { } sub cannonRect { - my $r = Qt::Rect(0, 0, 50, 50); + my $r = TQt::Rect(0, 0, 50, 50); $r->moveBottomLeft(rect()->bottomLeft); return $r; } @@ -159,19 +159,19 @@ sub shotRect { my $x = $x0 + $velx*$time; my $y = $y0 + $vely*$time - 0.5*$gravity*$time**2; - my $r = Qt::Rect(0, 0, 6, 6); - $r->moveCenter(Qt::Point(int($x), height() - 1 - int($y))); + my $r = TQt::Rect(0, 0, 6, 6); + $r->moveCenter(TQt::Point(int($x), height() - 1 - int($y))); return $r; } sub targetRect { - my $r = Qt::Rect(0, 0, 20, 10); - $r->moveCenter(Qt::Point(target->x, height() - 1 - target->y)); + my $r = TQt::Rect(0, 0, 20, 10); + $r->moveCenter(TQt::Point(target->x, height() - 1 - target->y)); return $r; } sub sizePolicy { - Qt::SizePolicy(&Qt::SizePolicy::Expanding, &Qt::SizePolicy::Expanding); + TQt::SizePolicy(&TQt::SizePolicy::Expanding, &TQt::SizePolicy::Expanding); } 1; diff --git a/PerlQt/tutorials/t12/LCDRange.pm b/PerlQt/tutorials/t12/LCDRange.pm index 3562fee..d3a5166 100644 --- a/PerlQt/tutorials/t12/LCDRange.pm +++ b/PerlQt/tutorials/t12/LCDRange.pm @@ -1,14 +1,14 @@ package LCDRange; use strict; -use Qt; -use Qt::isa qw(Qt::VBox); -use Qt::slots +use TQt; +use TQt::isa qw(TQt::VBox); +use TQt::slots setValue => ['int'], setRange => ['int', 'int'], setText => ['const char*']; -use Qt::signals +use TQt::signals valueChanged => ['int']; -use Qt::attributes qw( +use TQt::attributes qw( slider label ); @@ -25,17 +25,17 @@ sub NEW { sub init { - my $lcd = Qt::LCDNumber(2, this, "lcd"); + my $lcd = TQt::LCDNumber(2, this, "lcd"); - slider = Qt::Slider(&Horizontal, this, "slider"); + slider = TQt::Slider(&Horizontal, this, "slider"); slider->setRange(0, 99); slider->setValue(0); - label = Qt::Label(" ", this, "label"); + label = TQt::Label(" ", this, "label"); label->setAlignment(&AlignCenter); - $lcd->connect(slider, SIGNAL('valueChanged(int)'), SLOT('display(int)')); - this->connect(slider, SIGNAL('valueChanged(int)'), SIGNAL('valueChanged(int)')); + $lcd->connect(slider, TQT_SIGNAL('valueChanged(int)'), TQT_SLOT('display(int)')); + this->connect(slider, TQT_SIGNAL('valueChanged(int)'), TQT_SIGNAL('valueChanged(int)')); setFocusProxy(slider); } diff --git a/PerlQt/tutorials/t12/t12.pl b/PerlQt/tutorials/t12/t12.pl index 87c50be..e8072ef 100644 --- a/PerlQt/tutorials/t12/t12.pl +++ b/PerlQt/tutorials/t12/t12.pl @@ -4,8 +4,8 @@ use blib; package MyWidget; use strict; -use Qt; -use Qt::isa qw(Qt::Widget); +use TQt; +use TQt::isa qw(TQt::Widget); use LCDRange; use CannonField; @@ -13,10 +13,10 @@ use CannonField; sub NEW { shift->SUPER::NEW(@_); - my $quit = Qt::PushButton("&Quit", this, "quit"); - $quit->setFont(Qt::Font("Times", 18, &Qt::Font::Bold)); + my $quit = TQt::PushButton("&Quit", this, "quit"); + $quit->setFont(TQt::Font("Times", 18, &TQt::Font::Bold)); - Qt::app->connect($quit, SIGNAL('clicked()'), SLOT('quit()')); + TQt::app->connect($quit, TQT_SIGNAL('clicked()'), TQT_SLOT('quit()')); my $angle = LCDRange("ANGLE", this, "angle"); $angle->setRange(5, 70); @@ -26,28 +26,28 @@ sub NEW { my $cannonField = CannonField(this, "cannonField"); - $cannonField->connect($angle, SIGNAL('valueChanged(int)'), SLOT('setAngle(int)')); - $angle->connect($cannonField, SIGNAL('angleChanged(int)'), SLOT('setValue(int)')); + $cannonField->connect($angle, TQT_SIGNAL('valueChanged(int)'), TQT_SLOT('setAngle(int)')); + $angle->connect($cannonField, TQT_SIGNAL('angleChanged(int)'), TQT_SLOT('setValue(int)')); - $cannonField->connect($force, SIGNAL('valueChanged(int)'), SLOT('setForce(int)')); - $force->connect($cannonField, SIGNAL('forceChanged(int)'), SLOT('setValue(int)')); + $cannonField->connect($force, TQT_SIGNAL('valueChanged(int)'), TQT_SLOT('setForce(int)')); + $force->connect($cannonField, TQT_SIGNAL('forceChanged(int)'), TQT_SLOT('setValue(int)')); - my $shoot = Qt::PushButton('&Shoot', this, "shoot"); - $shoot->setFont(Qt::Font("Times", 18, &Qt::Font::Bold)); + my $shoot = TQt::PushButton('&Shoot', this, "shoot"); + $shoot->setFont(TQt::Font("Times", 18, &TQt::Font::Bold)); - $cannonField->connect($shoot, SIGNAL('clicked()'), SLOT('shoot()')); + $cannonField->connect($shoot, TQT_SIGNAL('clicked()'), TQT_SLOT('shoot()')); - my $grid = Qt::GridLayout(this, 2, 2, 10); + my $grid = TQt::GridLayout(this, 2, 2, 10); $grid->addWidget($quit, 0, 0); $grid->addWidget($cannonField, 1, 1); $grid->setColStretch(1, 10); - my $leftBox = Qt::VBoxLayout; + my $leftBox = TQt::VBoxLayout; $grid->addLayout($leftBox, 1, 0); $leftBox->addWidget($angle); $leftBox->addWidget($force); - my $topBox = Qt::HBoxLayout; + my $topBox = TQt::HBoxLayout; $grid->addLayout($topBox, 0, 1); $topBox->addWidget($shoot); $topBox->addStretch(1); @@ -58,11 +58,11 @@ sub NEW { } package main; -use Qt; +use TQt; use MyWidget; -Qt::Application::setColorSpec(&Qt::Application::CustomColor); -my $a = Qt::Application(\@ARGV); +TQt::Application::setColorSpec(&TQt::Application::CustomColor); +my $a = TQt::Application(\@ARGV); my $w = MyWidget; $w->setGeometry(100, 100, 500, 355); |