Results 1 to 5 of 5

Thread: QT4 - get content of a QAbstractItemModel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default QT4 - get content of a QAbstractItemModel

    I have this piece of code that I found on the forum :
    Qt Code:
    1. QListView *lv; // I use a QListView to view my QAbstractItemModel
    2. ...
    3. QItemSelectionModel *sel = lv->selectionModel();
    4. bool third = sel->isRowSelected(3, lv->rootIndex()); // check if row "3" is selected
    5. QModelIndexList list = sel->selectedIndexes();
    6. foreach(QModelIndex index, list){
    7. qDebug("Row %d selected", index.row());
    8. }
    To copy to clipboard, switch view to plain text mode 

    How can adapt it to read the content of the model row by row without foreach ?
    In fact I need the contents of rows 3,4, up to rowCount().

    Could I do foreach and have :
    Qt Code:
    1. foreach(QModelIndex index, list){
    2. if (index.row() > 2) qDebug("Row %d selected", index.row());
    3. }
    To copy to clipboard, switch view to plain text mode 
    But how do I set the index to contain all rows (selected or not) ?
    And how can I get the actual value for each index ?
    Last edited by incapacitant; 17th March 2006 at 17:43.

Similar Threads

  1. How to make QAbstractItemModel 's data checkable
    By nifei in forum Qt Programming
    Replies: 12
    Last Post: 1st April 2013, 19:52
  2. Creating a QAbstractItemModel for QTreeView
    By hbill in forum Qt Programming
    Replies: 13
    Last Post: 14th August 2008, 16:01
  3. Replies: 5
    Last Post: 20th April 2008, 20:30
  4. QAbstractItemModel to different views
    By ganeshshenoy in forum Qt Programming
    Replies: 3
    Last Post: 19th February 2008, 13:43
  5. Printing the content
    By veda in forum Qt Programming
    Replies: 7
    Last Post: 27th December 2007, 12:03

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
  •  
Qt is a trademark of The Qt Company.