Re: Help with connect
Roy Souther <[email protected]> Sun, 03 Jul 2005 17:21:24 -0600
| Newsgroups | gmane.comp.kde.devel.perl |
|---|---|
| Organization | Silicon Tao Technology Systems Inc. |
| Message-ID | <1120432884.13440.7.camel@UtopiaPlanetia> |
I am not an expert with PerlQt but I am an expert with Qt C++. These are the problems I found with your code and I have attached the fixed version. 1) PushButtons do not have a slot for setText. You cannont connect an event to that as a slot. 2) Slots must take only arguments given by the signal. You tried to give it a contant that was not in the signal. 3) Slots can only exist in an object not linear code like you tired to do. To fix this I changed your linear code to an object. Connected the signal event to a actual slot and made the slot change the text like you tried. I hope this helps to explain why your code did not work and my fix does. On Sun, 2005-07-03 at 12:41 +0200, Andrea Benazzo wrote: > Hi! > > I need some help with the signal-slot machine... > > I created this little script, but I've a problem with the correctness of the > "connect". > > > please, tell me where's the error, since I've lsot a couple of hours till > now, but I found nothing, > > I attach the script. > > Thank you, > > Andy > _______________________________________________ > Kde-perl mailing list > [email protected] > https://mail.kde.org/mailman/listinfo/kde-perl Roy Souther www.SiliconTao.com Let Open Source help your business move beyond. For security this message is digitally authenticated by GnuPG. _______________________________________________ Kde-perl mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-perl
test.pl
(application/x-perl, 1.5 KB)
#!/usr/bin/perl
use strict;
package MyDialog;
use Qt;
use Qt::isa qw(Qt::Widget);
use Qt::slots
OnButtonClick => [];
sub NEW
{
my $self = shift;
$self->SUPER::NEW(@_);
this->setCaption("Display the stem");
#setting the layout&title
this->{vertical}=Qt::VBoxLayout(this,5,7,"vertical");
this->{title}=Qt::Label("Find the stem of an Arabic word",this,"title");
this->{vertical}->addWidget(this->{title});
this->{box}=Qt::GridLayout(undef,2,2,5,7,"box");
this->{vertical}->addLayout(this->{box});
#setting the input text edit
this->{lb_input}=Qt::Label ("Input word:",this,"label");
this->{box}->addWidget(this->{lb_input},1,1);
this->{te_input}=Qt::TextEdit("",undef,this,"input word");
this->{box}->addWidget(this->{te_input},1,2);
#setting the Stem button
this->{pb_stem}=Qt::PushButton("&Stem", this,"stem button");
this->{box}->addWidget(this->{pb_stem},1,3);
#setting the output text edit
this->{lb_stem}=Qt::Label ("Stem:",this,"label2");
this->{box}->addWidget(this->{lb_stem},2,1);
this->{te_output}=Qt::TextEdit("",undef,this,"output stem");
this->{te_output}->setReadOnly(1);
this->{box}->addWidget(this->{te_output},2,2);
this->connect(this->{pb_stem}, SIGNAL('clicked()'), SLOT('OnButtonClick()'));
#setting the Quit button
this->{pb_quit}=Qt::PushButton("&Quit", this);
this->{vertical}->addWidget(this->{pb_quit},1,3);
}
sub OnButtonClick
{
this->{pb_stem}->setText("Dude");
}
1;
package Main;
my $app = Qt::Application(\@ARGV);
my $wid = new MyDialog;
$app->setMainWidget($wid);
$wid->show;
exit $app->exec;
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBCyHL0Y62fql08qicRAl2+AJ9HK/m2dsoicxbQYpEkqY60tEEuUQCgi4tB HTJovFMsHMD36Cn6oVVLL98= =Gke5 -----END PGP SIGNATURE-----