comboBox1->addItem(tr("something"), QVariant(1));comboBox1->addItem(tr("another"), QVariant(2));...int code = comboBox1->itemData(comboBox1->currentIndex(), Qt::UserRole).toInt();