Re: QListViewItem

Arnaud DUPUIS <[email protected]> Sat, 28 Oct 2006 09:33:33 +0200
Newsgroups gmane.comp.kde.devel.perl
Organization [ Infinity Perl ]
Message-ID <[email protected]>
Aaaaaahhhh ! Sorry I though that was what you wanted (all data in one singl=
e =

item) !!
So the problem is even simplier to solve : you instanciate only one =

QListViewItem and then replace the content of it at each loop iteration, if =

you want more than one QListViewItem, instanciate more than of this =

object ;-)

foreach (@array) {
	my $item =3D Qt::ListViewItem(listView1);
	$item->setText(0, trUtf8($_) );
}

you can also use another constructor form to set the text at instanciation.

I think you should read the Qt doc about QListView and QListViewItem =

("assistant" is provided with all Qt distro and is a great help).

Good day.


Le vendredi 27 octobre 2006 19:58, crazyroot a =E9crit=A0:
> Tnx, but, when I use this code:
>
>     my $item =3D Qt::ListViewItem(listView1, undef);
>           foreach $line (@array) {
>
>                          $item->setText(0, trUtf8($item->text(0)."$line")=
);
>      }
>
>
> for example, @array looks like this test1,test2,test3,test4...
> this code will add data in only one line, there is no newline per $line.
>
> Arnaud DUPUIS wrote:
> > Try this :
> > my $item =3D Qt::ListViewItem(listView1, undef);
> > $item->setText(0, trUtf8( join('',@array) ));
> >
> > Your loop replace the text content each time you go through the loop, if
> > you absolutly want to use your loop modify it this way :
> >  foreach loop. The code looks like this:
> >
> >     my $item =3D Qt::ListViewItem(listView1, undef);
> >           foreach $line (@array) {
> >
> >                          $item->setText(0,
> > trUtf8($item->text(0)."$line")); }
> >
> > Good day.
> >
> > Le vendredi 27 octobre 2006 11:24, crazyroot a =E9crit :
> >> Hi,
> >>
> >> I have listView on form , and I want to add data from array trough
> >> foreach loop. The code looks like this:
> >>
> >>    my $item =3D Qt::ListViewItem(listView1, undef);
> >>          foreach $line (@array) {
> >>
> >>                         $item->setText(0, trUtf8("$line"));
> >>     }
> >>
> >>   but, this add's only last record from array.
> >>
> >> Help please.
> >>
> >> _______________________________________________
> >> Kde-perl mailing list
> >> [email protected]
> >> https://mail.kde.org/mailman/listinfo/kde-perl
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Kde-perl mailing list
> > [email protected]
> > https://mail.kde.org/mailman/listinfo/kde-perl
>
> _______________________________________________
> Kde-perl mailing list
> [email protected]
> https://mail.kde.org/mailman/listinfo/kde-perl

-- =



DUPUIS Arnaud

[ Infinity Perl ]
http://slackget.infinityperl.org

"Slackware : because it works"
slack-get : because it rocks !
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
gpg id : 0xAC37E1B0
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D