logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: Subclasses and signals with PerlQT: msg#00050

Subject: Re: Subclasses and signals with PerlQT
On Thu, Jul 29, 2004 at 12:32:15PM +0200, Cervera.External@xxxxxxxxxxxx wrote:
> Is there a way to connect a signal in a class B which inherits from a
> class A, where this signal is implemented?
> I have tried, but the signal is never emitted!

I probably misundertand what you are trying to acheive, but it seems to
work pretty straightforwardly :

use Qt;

package Darth;
use Qt::isa qw/ Qt::Widget /;

sub NEW {
        shift->SUPER::NEW(@_[0..2]);
        this->connect( this, SIGNAL("useTheForce()"), SLOT( "feelTheForce()") );
}

sub useTheForce : SIGNAL();

sub feelTheForce : SLOT() {
        print this." feels a disturbance in the Force\n";
}

package Padawan;
use Qt::isa qw/ Darth /;

sub NEW {
        shift->SUPER::NEW(@_[0..2]);

        this->connect( this, SIGNAL( 'useTheForce()' ), SLOT('react()') );
}

sub react : SLOT() {
        print "It felt like a million toes wiggling\n";
}

package main;
use Qt;
use Darth;
use Padawan;
my $a = Qt::Application;

my $vader = Darth;
emit( $vader->useTheForce() );

my $luke = Padawan;
emit( $luke->useTheForce() );

exit $a->exec;


Joy,
`/anick
-- 
"The longer I live the more I see that I am never wrong about anything, and that
all the pains that I have so humbly taken to verify my notions have only wasted 
my
time." - George Bernard Shaw (1856-1950)



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>