At one point I had an SQL model directly attached, but I couldn't get at the table ID of the model. The displayed text in the combo box came from column 1 and the table ID was in column 0. Is there a way to get at the table ID in column 0 that I can't figure out?.... I just found a way, but it is ugly. Here it is...is there a better way?
int row = ui.comboBox->currentIndex();
int id = ui.comboBox->model()->data(idx).toInt();
qDebug() << id;
int row = ui.comboBox->currentIndex();
QModelIndex idx = ui.comboBox->model()->index(row, 0);
int id = ui.comboBox->model()->data(idx).toInt();
qDebug() << id;
To copy to clipboard, switch view to plain text mode
Bookmarks