Results 1 to 2 of 2

Thread: Get an Index inside a TableView[SOLVED]

  1. #1
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Get an Index inside a TableView[SOLVED]

    Hi,

    I need to go through a TableView, obtain some data... and since now I did something like:

    Qt Code:
    1. QAbstractItemModel* tableModel;
    2. QModelIndex index;
    3.  
    4. tableModel = my_TableView->model();
    5. index = my_TableView->currentIndex();
    6.  
    7. for(int i = 0; i < tableModel->rowCount(); ++i)
    8. {
    9. iIDList->append(tableModel->data(index.sibling(i, 4)).toInt());
    10. }
    11.  
    12. tableModel = 0;
    To copy to clipboard, switch view to plain text mode 

    But now I don't have any index selected... so "currentIndex()" sends null.

    Any idea how I can solve it? thanks!
    Last edited by jano_alex_es; 15th May 2009 at 08:08.

  2. #2
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Get an Index inside a TableView[SOLVED]

    Sorry, my bad... hours working around this problem and once I open a thread in the forum, I found the answer :S

    Anyway, the solution was impossible to be easier, something as simple as:
    index = tableModel->index(0, 0);

Similar Threads

  1. QTreView::isExpanded ( index ) allways false ?
    By jpujolf in forum Qt Programming
    Replies: 3
    Last Post: 24th September 2010, 10:23
  2. Obtain index of child's parent
    By webquinty in forum Qt Programming
    Replies: 4
    Last Post: 11th May 2009, 11:57
  3. Replies: 3
    Last Post: 25th July 2008, 14:30
  4. QProcess readStdOut index
    By user_mail07 in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2008, 19:37
  5. Qtopia core 4.2.2 cross compile make error
    By smiyai18 in forum Installation and Deployment
    Replies: 2
    Last Post: 28th August 2007, 17:04

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.