Results 1 to 2 of 2

Thread: QListView current row index?

  1. #1
    Join Date
    Dec 2012
    Posts
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default QListView current row index?

    cann`t find right function in QAbstractItemModel for recive current row index.

    Qt Code:
    1. ..........
    2. model = new QStringListModel(this);
    3.  
    4. ui->setupUi(this);
    5. ui->listView->setModel(model);
    6. ui->listView->setEditTriggers(QAbstractItemView::AnyKeyPressed);
    7. .........
    8. connect(ui->listView,SIGNAL(clicked(QModelIndex)),this,SLOT(itemchange(QModelIndex)));
    9. ............
    10. ..........
    11. void MainWindow::itemchange(QModelIndex modelindex)
    12. {
    13. int index = model-> //??????????
    14. qDebug() << index;
    15. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QListView current row index?

    You have to get it from QModelIndex (not from QAbstractItemModel)
    Qt Code:
    1. int QModelIndex::row () const
    To copy to clipboard, switch view to plain text mode 
    Last edited by Santosh Reddy; 3rd February 2013 at 18:35.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. How to get current focus index in QML ???
    By duc_bkav in forum Qt Programming
    Replies: 0
    Last Post: 25th November 2011, 04:28
  2. get initial row index of QListView after sorting?
    By lisarden in forum Qt Programming
    Replies: 6
    Last Post: 28th March 2011, 13:13
  3. Replies: 3
    Last Post: 11th August 2010, 13:47
  4. Connect button and pass QListView current index
    By been_1990 in forum Qt Programming
    Replies: 3
    Last Post: 30th November 2009, 16:20
  5. How to get current row(column) index in the QTextTable?
    By denny.t in forum Qt Programming
    Replies: 3
    Last Post: 5th April 2006, 07:53

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.