Key/Value pyqt QComboBox
Posted
by Danilo
on Stack Overflow
See other posts from Stack Overflow
or by Danilo
Published on 2010-04-20T13:07:50Z
Indexed on
2010/04/20
13:23 UTC
Read the original article
Hit count: 353
I want to use a QComboBox with the "keys" and "values" from a tuple similar to the ones used in a django models. For example I have the following structure for a person's sex.
SEX_CHOICES = (('M', 'Male'), ('F', 'Female'))
The first item of the tuple contains the code of the sex that is stored in the database, and the second one the text that I want to display in the QComboBox as an item.
Is there a way in wich I could set the QComboBox value as M and it displays Male. An also when the user select the element Male I could get the selected value as M.
Thanks
© Stack Overflow or respective owner