[Qt-interest] Select index of comboBox with item Data (ID)
Matthias Pospiech
matthias.pospiech at gmx.de
Sun Jun 27 22:39:41 CEST 2010
I can use the userData of a comboBox to save IDs together with the display text.
I can set these IDs using either
myCombo->setItemData(i, variantId);
or
myCombo->addItem("Text", variantId);
I can get the ID for a known index using
QVariant variantId = myCombo->itemData(myCombo->getCurrentIndex());
But how do I select the index using an ID?
Is this the only option?
myCombo->setCurrentIndex(myCombo->findData(variantID));
I am asking because I would have expected something like
myCombo->selectItem(variantID);
Matthias
More information about the Qt-interest-old
mailing list