If you have a data model based on QAbstractItemModel
which has to columns 'id' and 'name', you can do this:
enum Columns
{
COL_ID,
COL_NAME
}
QComboBox *combo = new QComboBox;
combo->setModel(model);
combo->setModelColumn(COL_NAME)
If you want to add items to a combobox one by one, you do this:
QComboBox *combo = new QComboBox;
combo->addItem(name, id);
Then you can retrieve id value from combobox item using:
QString id = combo->itemData(index, Qt::UserRole).toString();