Results 1 to 3 of 3

Thread: Help need for sorting elements in QCombobox

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Help need for sorting elements in QCombobox

    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.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Help need for sorting elements in QCombobox

    Look at qSort() function

  3. #3
    Join Date
    Apr 2009
    Posts
    46
    Thanks
    4
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Help need for sorting elements in QCombobox

    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.

Similar Threads

  1. Cutting Elements QStringlist
    By codeman in forum Qt Programming
    Replies: 3
    Last Post: 5th June 2009, 11:19
  2. elements not updated
    By danesh in forum Qt Programming
    Replies: 2
    Last Post: 2nd April 2009, 08:35
  3. Sorting elements in QTableWidget
    By Elmo23x in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 08:35
  4. Elements out of Range!!
    By Kapil in forum Newbie
    Replies: 9
    Last Post: 3rd April 2006, 10:28
  5. Qt4.1.1: Sorting QCombobox entries
    By Byngl in forum Qt Programming
    Replies: 4
    Last Post: 17th March 2006, 09:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.