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

Stephan Bosch <[email protected]> Sat, 18 Feb 2006 02:14:45 +0100
Newsgroups gmane.comp.kde.devel.perl
Message-ID <[email protected]>
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.