#!/usr/bin/perl -w # Pfad des Perl-Interpreters use strict; #............................................................ class Schrift package Schrift; use Qt; # Laden des PerlQt-Moduls use Qt::isa qw(Qt::Label); # Klasse Schrift erbt Qt::Label use Qt::slots stelle_neu_dar => [ 'int' ]; sub NEW { #... Schrift-Konstruktor shift->SUPER::NEW(@_[0..2]); setCaption("PerlQt Beispiel zur Schriftgrößenänderung"); } sub stelle_neu_dar { # Slotroutine my $value = shift; setFont( Qt::Font("Times", $value) ); } #..................................................................... main package main; use Qt; # Laden des PerlQt-Moduls use Schrift; # package Schrift importieren my $app = Qt::Application(\@ARGV); my $mywidget = Qt::Widget; $mywidget->setGeometry( 400, 300, 550, 150 ); my $myslider = Qt::Slider(0, 99, 1, 20, &Qt::Horizontal, $mywidget, "Slider"); $myslider->setGeometry( 10, 10, 180, 30 ); my $mylcdnum = Qt::LCDNumber( 2, $mywidget ); $mylcdnum->setGeometry( 60, 50, 80, 50 ); $mylcdnum->display( 20 ); $mylcdnum->connect( $myslider, SIGNAL 'valueChanged(int)', SLOT 'display(int)' ); my $decrement = Qt::PushButton( "<", $mywidget ); $decrement->setGeometry( 10, 110, 50, 30 ); $decrement->setFont(Qt::Font("Times", 18, &Qt::Font::Bold) ); $decrement->setPaletteBackgroundColor( Qt::Color(255, 0, 0) ); my $increment = Qt::PushButton( ">", $mywidget ); $increment->setGeometry( 140, 110, 50, 30 ); $increment->setFont(Qt::Font("Times", 18, &Qt::Font::Bold) ); $decrement->setPaletteBackgroundColor( Qt::Color(0, 255, 0) ); $myslider->connect( $decrement, SIGNAL 'clicked()', SLOT 'subtractStep()' ); $myslider->connect( $increment, SIGNAL 'clicked()', SLOT 'addStep()' ); my $anzeige = Schrift( " Text", $mywidget); $anzeige->setGeometry( 200, 10, 340, 130 ); $anzeige->setFont(Qt::Font("Times", 20) ); $anzeige->setPaletteBackgroundColor( &Qt::white ); $anzeige->connect( $myslider, SIGNAL 'valueChanged(int)', SLOT 'stelle_neu_dar(int)' ); $app->setMainWidget($mywidget); $mywidget->show; exit $app->exec;