[Kde-perl] removing rows in QTable

Stefan Schwertheim S.Schwertheim at t-online.de
Sat Feb 14 08:26:26 CET 2004


Hello,

I have a problem with QTable.
I can append a row and set the text for a cell
but i am not able to remove the row with a QTableItem.
Every time I try that I get a segmention fault.

What's wrong.
I have tried the following example with PerlQt-3.008 and PerlQt-cvs.

any help is appreciate

bye Stefan

  ### Code ########################
use strict;
use utf8;

package Form4;
use Qt;
use Qt::isa qw(Qt::Dialog);
use Qt::slots
     PB_append_clicked => [],
     PB_remove_clicked => [];
use Qt::attributes qw(
     pushButton15
     pushButton18
     table
);

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

     if ( name() eq "unnamed" )
     {
         setName("Form4" );
     }

     pushButton15 = Qt::PushButton(this, "pushButton15");
     pushButton15->setGeometry( Qt::Rect(20, 240, 120, 29) );

     pushButton18 = Qt::PushButton(this, "pushButton18");
     pushButton18->setGeometry( Qt::Rect(160, 240, 120, 29) );

     table = Qt::Table(this, "table");
     table->setGeometry( Qt::Rect(20, 20, 370, 200) );
     table->setNumRows( int(1) );
     table->setNumCols( int(1) );
     languageChange();
     my $resize = Qt::Size(416, 291);
     $resize = $resize->expandedTo(minimumSizeHint());
     resize( $resize );
     clearWState( &Qt::WState_Polished );

     Qt::Object::connect(pushButton15, SIGNAL "clicked()", this, SLOT 
"PB_append_clicked()");
     Qt::Object::connect(pushButton18, SIGNAL "clicked()", this, SLOT 
"PB_remove_clicked()");
}

sub languageChange
{
     setCaption(trUtf8("Form4") );
     pushButton15->setText( trUtf8("append") );
     pushButton18->setText( trUtf8("remove") );
}


sub PB_append_clicked
{
     my $tmp = table->numRows();
     table->insertRows($tmp, 1);
     table->setText($tmp, 0, "Append Row $tmp");
}

sub PB_remove_clicked
{
     my $tmp = table->numRows();
     table->removeRow($tmp - 1);
}

1;

package main;

use Qt;
use Form4;

my $a = Qt::Application(\@ARGV);
my $w = Form4;
$a->setMainWidget($w);
$w->show;
exit $a->exec;

  ### Code end ####################
-- 
Stefan Schwertheim
Neustr. 8
45891 Gelsenkirchen

S.Schwertheim at t-online.de


More information about the Kde-perl mailing list