David Boddie wrote:
On Thursday 19 April 2007 12:53:08 +0200, Tina I wrote:
I have a QComboBox (Qt4) where I want to insert items alphabetically.
[...]
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?
QComboBox doesn't provide any support for sorting itself. You could either
sort the list in advance or, if you need the unsorted list elsewhere, you
could use some technique for inserting the items in the correct order.
If it doesn't seem like a wasteful operation, you could just sort a copy of
the list and insert that into the combo box. You could even create a
QStringList, sort it, and pass that into QComboBox::addItems().
David
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
D'oh! I always seem to overcomplicate things when working with Qt.
list.sort() does the job perfectly...
Thanks!
Tina
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt