Qt: c++: How to create a SIGNAL/SLOT when selecting a row in QTableView
c++, model, qt, qtableview
Solution
You can do it in this way:
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
SLOT(slotSelectionChange(const QItemSelection &, const QItemSelection &))
);
And the slot would be:
void MainWindow::slotSelectionChange(const QItemSelection &, const QItemSelection &)
{
QModelIndexList selection = ui->tableView->selectionModel()->selectedRows();//Here you are getting the indexes of the selected rows
//Now you can create your code using this information
}
I hope this can help you.
Problem
I have a `QTableView` which is working properly showing my model on the GUI. however, I would like to create a "SIGNAL/SLOT" that works when I select a row from the `QTableView`. How can I do that?