PDA

View Full Version : How can I get the value of the clicked cell in a QListView



murari2002
27th September 2007, 13:36
How can I get the value of the clicked cell in a QListView ??

Hello its very urgent and I am not able to find any way ahead.
How can we get the value or the text of the clicked cell in a QListView

listView1->text(0)

gives the text of the first column. But I need for any cell.

Thanks for the help.
you can also mail me at murari@tataelxsi.co.in

Please do help as soon as possible.

Regards
Murari Singh

rajesh
27th September 2007, 14:10
Murari,

I think you try this:

connect(listView1,SIGNAL(clicked ( const QModelIndex & index )),this,SLOT(showData(
QModelIndex index )));

void myClass::showData(QModelIndex index)
{

QString str = listView1.data(index).toString();

}

or
can you give your code, how you adding data to QListView?

jpn
27th September 2007, 17:18
Hello its very urgent
http://catb.org/~esr/faqs/smart-questions.html#urgent



How can we get the value or the text of the clicked cell in a QListView

listView1->text(0)

gives the text of the first column. But I need for any cell.

So connect to a signal which passes the column as parameter: QListView::clicked ( QListViewItem * item, const QPoint & pnt, int c ) (http://doc.trolltech.com/3.3/qlistview#clicked-2). The last parameter is the one you're interested in.

If item is not 0, c is the list view column into which the user pressed; if item is 0 c's value is undefined.