Results 1 to 5 of 5

Thread: QSort

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QSort

    Hi,

    I have a problem with qSort, illustrated as follows:

    Qt Code:
    1. #include <qhash.h>
    2.  
    3. struct TDATA {
    4. QString emp_name;
    5. float salary;
    6. };
    7.  
    8. QHash < uint, TDATA> emps;
    9.  
    10. bool salaryLessThan(const TDATA &e1, const TDATA &e2) {
    11. return (e1.salary < e2.salary);
    12. }
    13.  
    14. int main(int argc, char *argv[])
    15. {
    16.  
    17. qStableSort(emps.begin(), emps.end(), salaryLessThan);
    18. return 1;
    19. }
    To copy to clipboard, switch view to plain text mode 
    Basically, I want to sort based on the values in the Hash.

    Compiling this gives a long error message as attached:

    Can anyone please help me out?

    Thanks.
    Attached Files Attached Files
    Last edited by jpn; 2nd December 2008 at 09:25. Reason: missing [code] tags

Similar Threads

  1. Sorting using qSort(), - if QList contains POINTERS
    By joseph in forum Qt Programming
    Replies: 13
    Last Post: 18th August 2013, 18:55
  2. qSort with lessThan
    By soul_rebel in forum Qt Programming
    Replies: 4
    Last Post: 19th August 2008, 18:14
  3. qSort() problem
    By darksaga in forum Qt Programming
    Replies: 5
    Last Post: 17th August 2007, 11:47
  4. qSort doesn't work with member function
    By ber_44 in forum Qt Programming
    Replies: 10
    Last Post: 2nd June 2007, 12:00
  5. [Qt4] QSORT
    By jane in forum Qt Programming
    Replies: 6
    Last Post: 24th May 2006, 23:38

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.