Thank you both for your responses!

As it happens, the setDefaultProperty isn't useful to me in this instance. I was assuming that the combo-box would be similar to a HTML select-box. I'm very new to desktop application development. I figured that each selectable item could have a value assigned to it but a different text label. In this case, the QComboBoxes were being populated by QSqlTableModel objects, so I was hoping that I could display one table column as the text and have the primary key 'id' column, for example, as the "value" of the item. Unfortunately, that doesn't appear to be the case.

norobro, your answer is the similar to the solution I found! I ended up having to pull the data back from the table model, based on the currentIndex of the QComboBox and the column I wanted to access, using a QModelIndex. Essentially, I'm doing the following:

Qt Code:
  1. model->setData(model->index(row, Patient::EmploymentStatus),
  2. model->employmentStatus()->index(field("employment_status").toInt(), model->employmentStatus()->fieldIndex("code")).data());
To copy to clipboard, switch view to plain text mode 

I don't have direct access to the QComboBox object at the stage I'm trying to access the values, which is why I couldn't do ui->comboBox->blahblah and instead had to pull from the model again.

I'm pretty sure that what I'm doing is fairly inefficient, so if there's a better way of doing this, I'd love to know. In general, if there are any in-depth examples of working with QSql*Models then I'd love to know about them.

By the way, Lykurg, the database makes up part of a patient management system for general practice clinics (built for my university project) and those attributes are a small sample of the details that the NHS stores.

Thanks again, guys.