[PyKDE] Re: Using comboboxes indexes for referencing data

Jorge Godoy godoy at ieee.org
Tue May 10 22:44:07 BST 2005

Jim Bublitz <jbublitz at nwinternet.com> writes:

> In the case of QComboBox, "index" refers to an item's position in the combo 
> box's list of items. The list of items is a list of strings.

Pity. :-(  I was happy thinking I could do that as with wxPython. 

> There are a number of ways to do what you want, but they would be things like 
> maintaining a separate data structure which maps items and (your) index 
> values, or subclassing QComboBox to do that for you automatically. The 
> implementation would depend a lot on your application.

I'll have to take a look at this.  For now, all cases contained unique values,
so I could get the text and find the correct reference to it, but I would
really like having this possibility.

Do you think that using a dict would be enough?  The key would be the position
in the combobox and the value would be what I want (either another number or
some text).  I think it would be enough...

Subclassing QComboBox, on the other hand, might be interesting if I can make
this subclass behaves like a combobox with KDevDesigner.

Thanks for you help, Jim.

Be seeing you,
Jorge Godoy      <godoy at ieee.org>

More information about the PyQt mailing list