Re: Write access to inherited attributes - was: Method returning non-scalar
Ole Christensen <[email protected]> Tue, 23 Nov 2004 17:20:54 +0100
| Newsgroups | gmane.comp.kde.devel.perl |
|---|---|
| Message-ID | <[email protected]> |
Germain, please find attached a test case - not really minimal but a test case - 81 lines. This is what happens: Can't modify non-lvalue subroutine call at qt_attr.pl line 45. I have marked line 45 in the source. I will try your patch for the list return issue asap. Maybe tonight. Thanks and cheers, Ole. Germain Garand wrote: > Le Mardi 23 Novembre 2004 07:41, Ole Christensen a écrit : > >>And another but final remark: It seems PerlQt attributes are writable >>from the package itself but not from inheritors. Read access works fine >>if preceeding the attribute with an "&". So they are a kind of between >>private and protected (borrowed from C++). Haven't tried pulic read >>access. That's another item for a FAQ I guess. >> >>Everthing above true and maybe only true for PerlQt 3.008. > > > mmh, I'll investigate that... have you, by chance, a minimal testcase at hand? > > Greetings, > Germain _______________________________________________ Kde-perl mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-perl
qt_attr.pl
(text/x-perl, 1.2 KB)
use strict;
use warnings;
package MyCommonItem;
use Qt;
use Qt::isa qw (Qt::CheckListItem);
use Qt::attributes qw (hilited);
sub NEW
{
my $this = shift;
$this -> SUPER::NEW (@_);
hilited = 0;
}
sub set_hilited
{
my $hilited = shift;
return if ($hilited == hilited);
hilited = $hilited;
repaint ();
a ($hilited);
}
sub a {}
1;
package MySpecialItem;
use Qt;
use Qt::isa qw (MyCommonItem);
# overload MyCommonItem::set_hilited
sub set_hilited
{
my $hilited = shift;
return if ($hilited == &hilited);
&hilited = $hilited; # this is line 45 <<<<<<<<<<<<<<<
repaint ();
b ($hilited);
}
sub b {}
package Window;
use Qt;
use Qt::isa qw (Qt::Widget);
use MyCommonItem;
use MySpecialItem;
sub NEW
{
my $this = shift;
$this -> SUPER::NEW (@_);
my $lv = Qt::ListView (this, "list_view");
my $it1 = MyCommonItem ($lv, "Hi there!", &Qt::CheckListItem::CheckBox);
my $it2 = MySpecialItem ($lv, "Hi again!", &Qt::CheckListItem::CheckBox);
$it1 -> set_hilited (1);
$it2 -> set_hilited (1);
}
package main;
use Qt;
use Window;
my $app = Qt::Application (\@ARGV);
my $win = Window ();
$app -> setMainWidget ($win);
$win -> show ();
exit ($app -> exec ());