I have a QComboBox (Qt4) where I want to insert items alphabetically. Pyuic4 generated this:

       self.depArea = QtGui.QComboBox(self.centralwidget)
       self.depArea.setInsertPolicy(QtGui.QComboBox.InsertAlphabetically)
       self.depArea.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
       self.depArea.setObjectName("depArea")
       self.hboxlayout1.addWidget(self.depArea)

And the code that inserts the items in my program:

   for select in range(len(airports.areasIncluded)):
self.ui.depArea.insertItem(select , airports.areasIncluded[select - 1])

'airports.areasIncluded' is a list of unicode elements. A snippet of it (it's very long):

areasIncluded = [u' Spain, Portugal', u' France', u' Greece', u' Italy', u' Estonia, Latvia, Lithuania', u' Poland']

The problem is of course that the item is inserted at position 'select' and not where it fits in the alphabet. And from the documentation I can not find any insert methods that does not require the 'index'. Am I missing something?

Any help will be greatly appreciated!
Thanks
Tina
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to