[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-perl
Subject:    Re: [Kde-perl] Why isn't this easy? implementing File->New
From:       darrik <darrik () mythofbutterfly ! com>
Date:       2006-08-02 5:52:01
Message-ID: 44D03D81.2040903 () mythofbutterfly ! com
[Download RAW message or body]

Ashley Winters wrote:
> use strict;
> use Qt;     # use Qt in EVERY package! It declares 'this', and does
> other use-strict-happy things
> use MyView;
> sub processFileMenu {
> 	if ($option==FILENEW) {
> 		MyView(this)->show;
> 	}
> }

You're not storing a perl reference to the new window anywhere.  What 
happens when you want to access that window from the parent later?

This is more evident when you subclass a container widget that has child 
controls.  For instance:

use strict;

package MyWidget;

use Qt;
use Qt::isa qw( Qt::Widget );

sub NEW {
   # irrelevant method arguments left out for brevity :P

   my $class=shift;
   my $parent=shift;
   shift->SUPER::NEW($parent);
   my $layout=Qt::HBoxLayout(this);
   my $lbl=Qt::Label("label",this);
   $layout->addWidget($lbl);
}

sub changeChildLabel {
   # how do you access $lbl here?
}

This part has me confused.  Storing $lbl in a package variable doesn't 
work if you instantiate several MyWidget's.  I've been using workarounds 
that are inelegant, so a pointer to the *proper* way to do this would be 
immensely appreciated.

Thanks,
Darrik Mazey
_______________________________________________
Kde-perl mailing list
Kde-perl@kde.org
https://mail.kde.org/mailman/listinfo/kde-perl
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic