PDA

View Full Version : Help need for sorting elements in QCombobox



narendra
6th January 2010, 06:36
Hi,
I have a QStringList and i use it to set the contents of QCombobox.

I want the contents in QcomboBox as sorted so i called a sort function on QStringList before setting it to QCombobox.

But the string in the list are sorted based on case also, i dont what this to happen. how to solve this problem.

Ex: Help, Ha, he Zan.
it sorts it like Ha, Help, Zan, he but i want it as Ha, he, Help, Zan.
I want to know how to do using built in function if possible ?
Please do replay is there a way or not.

Lesiok
6th January 2010, 06:45
Look at qSort() (http://doc.trolltech.com/4.6/qtalgorithms.html#qSort) function

RSX
6th January 2010, 06:48
In documentation you can read:

If you want to sort your strings in an arbitrary order, consider using the QMap class. For example, you could use a QMap<QString, QString> to create a case-insensitive ordering (e.g. with the keys being lower-case versions of the strings, and the values being the strings), or a QMap<int, QString> to sort the strings by some integer index.