Re: QIconView woes....

Ashley Winters <[email protected]> Sun, 21 Aug 2005 20:29:42 -0700 (PDT)
Newsgroups gmane.comp.kde.devel.perl
Message-ID <[email protected]>
--- Gary Greene <[email protected]> wrote:
> 
> I'm trying to get the selected QIconViewItem from a QIconView in a
> PerlQt app 
> I'm working on and I can't seem to connect the SIGNAL to SLOT for it.
> Here's 
> a snippet of code from the app:
> 
>             $drives[ $i ] = Qt::IconViewItem( $MainWidget::driveView,
>                                         &tr(
> "$driveName\n$roundedSize GB" ),
>                                              $drvIcon );
>             $MainWidget::driveView->connect( $MainWidget::driveView,
>                    SIGNAL "clicked( $driveView->currentItem() )",
>                    this,
>                    SLOT "&driveSelected()" );
>         }

well, you can't do SIGNAL "foo($variable)" since $variable can't be
interpreted at connect() time. Also, I don't think the "&" in
"&driveSelected()" is legal.

So, here's what you could do instead:

$driveView->connect(SIGNAL "clicked()", this, SLOT "driveSelected()");

In the driveSelected() slot, if you want to find out the current item,
you can call this->sender->currentItem(), or you could use your global
$MainWidget::driveView->currentItem(). Personally, I'd use
this->sender.

Ashley Winters


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