PDA

View Full Version : How to return elements from a ListView



nikau
23rd January 2007, 06:07
I know this is very simple but I havn't been able to get it to work yet!

I've been following this tutorial (http://www.digitalfanatics.org/projects/qt_tutorial/chapter05.html) but hit a wall when trying to solve the last excercise in chapter 5!!
I have created an application that takes input from a "lineedit" and displays it in a "ListView" Widget upon pressing an "Add" button.. I have two columns in the listview. One for the lineedit text and one for a counter (counting the number of entries added to the list)This works :)
Now I would like to change things so that when I select an Item in ListView, the text content of that item is displayed in a lineedit widget!
What is the command for doing this?? I've tried the following but no gain!

lineedit->insert(QListViewItem(listview->currentItem(),column1)->text());

lineedit and listview are the names of my widgets!

I hope someone out there will thake the time to help a poor disturbed QT Noob

Regards Nikau

e8johan
23rd January 2007, 07:44
You want to do something like lineEdit->setText( listView->currentItem()->text(0) );