The selectionChanged() signal gives you the new QItemSelection. If you have set the view to select rows then you can see if the first/last row is in the selection with by using QItemSelection::contains() with the QModelIndex of the first/last row and a visible column. If you allow selecting arbitrary items then you would have to check each item in the first/last row or you could also grab the selectionModel() of the view and use: QItemSelectionModel::isRowSelected().

You need to be careful to handle the case when both the first and last row are in the selection or when the view is empty.