[Kde-perl] slot searched in the base class instead of the derived one

Germain Garand kde-perl@mail.kde.org
Sat, 7 Dec 2002 13:21:05 +0000


Le Samedi 07 D=E9cembre 2002 12:40, Germain Garand a =E9crit :
> Le Samedi 07 D=E9cembre 2002 00:09, St=E9phane Payrard a =E9crit :
> > PerlQt barks:
> >
> > QObject::connect: No such slot QApplication::showdoc(int)
> > QObject::connect:  (sender name:   'unnamed')
> > QObject::connect:  (receiver name: 'sdoc')
> >
> > I am puzzled: why the slot is searched in Qt::Application
> > instead of my subclass DocAppli?
> > I am probably getting something wrong. But I can't see what.
>
> Ah, yes, damn, I forgot that : there are still problems with subclassin=
g
> the Qt::Application class (some hacks made it a bit special).
> I'll have a look and see if I can fix it before the release.
> However, for normal applications, and unless you really have a need to
> reimplement some Qt::Application virtuals, it is not recommended to sub=
clas
> it.... better subclass the MainWindow class for instance, since that wo=
uld
> be the real logical core of your app.
>
> G.

OK, fixed in CVS...=20
eg:

package DocAppli;
use strict;
use Qt;
use Qt::isa qw(Qt::Application);
use Qt::slots showdoc =3D> [ 'int' ];
sub showdoc { } # place-holder

sub NEW {
   shift->SUPER::NEW(@_);
}

sub showdoc { print "No=EBl au scanner, P=E2ques au cimeti=E8re !\n" }
1;

package main;
use Qt;
use DocAppli;

my $a  =3D DocAppli(\@ARGV);
my $m =3D Qt::MainWindow();
my $mb =3D $m->menuBar();
$mb->insertItem( "foo", $a, SLOT("showdoc(int)") );
$m->show;
$a->setMainWidget($m);
$a->exec();

Cheers,
Germain

>
> > Thx
>
> _______________________________________________
> Kde-perl mailing list
> Kde-perl@mail.kde.org
> http://mail.kde.org/mailman/listinfo/kde-perl