View Full Version : how to get item's text or path from QListVIew

Mystical Groovy
3rd September 2008, 15:12

I have a problem, I have a ListView that displays a list of items of a directory.
is there a way to copy selected item's text or path into a var using QListViewItem.



user selects item2 and then clicks a button, then item's text "item2" or item's path (e.x "/usr/bin/item2") is saved into a QString var.

is there a way to do that?
thank you, and sorry for my poor english.

3rd September 2008, 15:45
you can catch this signal http://doc.trolltech.com/3.3/qlistview.html#clicked in your widget and then use this method for getting the text http://doc.trolltech.com/3.3/qlistviewitem.html#text

or I didn't understand something?

Mystical Groovy
3rd September 2008, 15:57
hey spirit, thx for the anwser..

ill try to do it with these methods.:cool:

Mystical Groovy
3rd September 2008, 17:09
ok here's the code

//copy selected package name to pkgName var
listViewItem->setSelected( TRUE );
pkgName = ( listViewItem->text ( 0 ) );

then i click an item in the list and run a KMessageBox, but pkgName var is empty..
what am i doing wrong?

Mystical Groovy
5th September 2008, 01:25
ok problem solved, the solution was very easy after all ;)