I have this piece of code that I found on the forum :
QListView *lv;
// I use a QListView to view my QAbstractItemModel ...
bool third = sel->isRowSelected(3, lv->rootIndex()); // check if row "3" is selected
QModelIndexList list = sel->selectedIndexes();
qDebug("Row %d selected", index.row());
}
QListView *lv; // I use a QListView to view my QAbstractItemModel
...
QItemSelectionModel *sel = lv->selectionModel();
bool third = sel->isRowSelected(3, lv->rootIndex()); // check if row "3" is selected
QModelIndexList list = sel->selectedIndexes();
foreach(QModelIndex index, list){
qDebug("Row %d selected", index.row());
}
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 :
if (index.row() > 2) qDebug("Row %d selected", index.row());
}
foreach(QModelIndex index, list){
if (index.row() > 2) qDebug("Row %d selected", index.row());
}
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 ?
Bookmarks