Method 1a and 1b:
//...
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;
//...
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
Method 2:
//...
QModelIndexList list = lv->selectedItems(); // provided for convenience
qDebug("Row %d selected", index.row());
}
QListView *lv;
//...
QModelIndexList list = lv->selectedItems(); // provided for convenience
foreach(QModelIndex index, list){
qDebug("Row %d selected", index.row());
}
To copy to clipboard, switch view to plain text mode
Bookmarks