You can do it as follows:
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
SLOT(slotSelectionChange(const QItemSelection &, const QItemSelection &))
);
And the slot will be:
void MainWindow::slotSelectionChange(const QItemSelection &, const QItemSelection &)
{
QModelIndexList selection = ui->tableView->selectionModel()->selectedRows();
}
Hope this helps you.
source
share