I have a QTableView which is pulling a list of locations and latitude/longitude coordinates from an SQLite database. I want to extract the latitude and longitude from the row that the user has selected in the table, and am using the following code, but it looks fairly convoluted. Maybe I'm just not understanding how to fully utilize Qt's model/view system. Can I write this code in a clearer, more compact way?
QModelIndexList list1 = this->ui->tableView->selectionModel()->selectedRows(1);
QModelIndexList list2 = this->ui->tableView->selectionModel()->selectedRows(2);
if (list1.count() != 1 || (list1.count() != list2.count()))
{
return;
}
double latitude = list1.at(0).data().toDouble();
double longitude = list2.at(0).data().toDouble();