I'm new to pyqt and I'm having a question about QComboBox. I have one on a form that I would like to populate with data from a db-table. The table is very simple, it has only two columns, an id and a description. I would like to add the descriptions as items to the combobox with the id as index. (Something like: self.cmbSearch.insertItem(description, id)). But I'm getting 'index out of range' errors. Could this be because the indexes need to be in consecutive order (and the series of id's isn't) ? I can't find info on this in the pyqt-documentation...
I'm new myself, but I've done a few small apps since starting. The TrollTech docs are very useful (http://doc.trolltech.com/), but I didn't find an easy way to do what you're after (having a Combo Box with a "value" for each entry, a la HTML forms).
The way I got around it was to separately store a mapping (or what's the python term? Dictionary or something?) of either the labels, or the combo box index, to the values you're after. So, when you populate the entries in the field, also populate a mapping. Then, to get the value, you use the text or index to look up the mapping to get the value.
The index value of the combo box is solely a numeric item number for the items in the list (AFAIK).
-- . Trevor Phillips - http://jurai.murdoch.edu.au/ . : Web Technical Administrator - [EMAIL PROTECTED] : | IT Services - Murdoch University | >--------------------------------------------------------------------< | On nights such as this, evil deeds are done. And good deeds, of / | course. But mostly evil, on the whole. / \ -- (Terry Pratchett, Wyrd Sisters) /
_______________________________________________ PyKDE mailing list [EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
