Re: Perl QT: Problem using a custom Qt::Validator with a Qt:LineEdit

Ashley Winters <[email protected]> Fri, 17 Feb 2006 19:29:01 -0800 (PST)
Newsgroups gmane.comp.kde.devel.perl
Message-ID <[email protected]>
It might be a bug. Try this:

sub validate {
   my($string, $pos) = @_;
   print "Validate!\n";

   return this->Acceptable;
}

Ashley Winters

--- Stephan Bosch <[email protected]> wrote:

> Hello,
> 
> I am currently using PerlQt-3.008 (using Qt-3.3.3) for a simple
> design. 
> I am trying to build a custom Validator for a special LineEdit I
> need. I 
> have subclassed the Qt::Validator class with a very much empty 
> validate() method (it simply returns Qt::Validator::Acceptable). 
> However, when I have assigned an instance of the new Validator class
> to 
> my LineEdit, the program crashes with a segfault as soon as the text
> in 
> the LineEdit is edited.
> 
> The new validator class is structured as follows:
> 
> package TestValidator;
> use Qt;
> 
> use Qt::isa qw(Qt::Validator);
> 
> sub NEW {
>    shift->SUPER::NEW($_[0]);
> 
>    print "New validator!\n";
> }
> 
> sub validate {
>    my($string, $pos) = @_;
>    print "Validate!\n";
> 
>    return &Qt::Validator::Acceptable;
> }
> 
> 1;
> 
> The validator is assigned to the LineEdit as follows (where 'this' is
> an 
> instance of Qt::Dialog and edtTest is a Qt::LineEdit):
> 
> my $v = TestValidator( this );
> edtTest->setValidator( $v );
> 
> Upon editing the LineEdit the program crashes as follows:
> 
> New validator!
> Validate!
> Use of uninitialized value in subroutine entry at
> /usr/lib/perl5/Qt.pm 
> line 445.
> Segmentation fault
> 
> Unfortunately the Qt::debug feature does not yield any useful data.
> It 
> simply states that the validate method is called.
> 
> Does any of you know what causes this segfault? Is it a bug or am I 
> doing something wrong? A working perl-Qt example regarding custom 
> validators would be very much appreciated.
> 
> Regards,
> 
> Stephan.
> 
> _______________________________________________
> Kde-perl mailing list
> [email protected]
> https://mail.kde.org/mailman/listinfo/kde-perl
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com