Results 1 to 3 of 3

Thread: How can I get the value of the clicked cell in a QListView

  1. #1
    Join Date
    Sep 2007
    Posts
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default How can I get the value of the clicked cell in a QListView

    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

  2. #2
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: How can I get the value of the clicked cell in a QListView

    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?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How can I get the value of the clicked cell in a QListView

    Quote Originally Posted by murari2002 View Post
    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 ). 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.
    J-P Nurmi

Similar Threads

  1. QListView word wrap
    By serega in forum Qt Programming
    Replies: 17
    Last Post: 30th August 2007, 03:13
  2. Word wrapping in a QTableWidget cell
    By jcooperddtd in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2007, 03:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.