Use C++11's foreach loop over Qt's foreach. In that case you can even use
```C++
for (const QModelIndex& selectedIndex : friendView->selectionModel()->selectedIndexes()) {
```

Also, your for-loop shouldn't have the opening brace on the next line.