Results 1 to 3 of 3

Thread: QTreeView sorting

  1. #1
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTreeView sorting

    Hi All.
    I trying to use:
    Qt Code:
    1. struct FLess : public std::binary_function<HASH, HASH, bool>
    2. {
    3. int Col;
    4. static void setCol( int C );
    5.  
    6. inline bool operator()( const HASH &rec1, const HASH &rec2 )
    7. {
    8. return ( rec1.hash.value( Col ) < rec2.hash.value( Col ) );
    9. }
    10. };
    To copy to clipboard, switch view to plain text mode 
    In programm:
    Qt Code:
    1. FLess::setCol( 5 );
    2.  
    3. if (order == Qt::AscendingOrder)
    4. std::sort( Records[i].begin(), Records[i].end(), FLess() );
    To copy to clipboard, switch view to plain text mode 
    How make sort by Col?
    Thanks.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView sorting

    What exactly do you want to achieve, and why do you want to achieve that (that might help in helping you).
    Last edited by franz; 3rd May 2011 at 07:53.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView sorting

    If I put number, for example 5 all works normally
    Qt Code:
    1. return ( rec1.hash.value( 5 ) < rec2.hash.value( 5 ) );
    To copy to clipboard, switch view to plain text mode 
    I need to read out from a variable
    Qt Code:
    1. return ( rec1.hash.value( SomeVariable ) < rec2.hash.value( SomeVariable ) );
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTableView sorting
    By realdarkman71 in forum Newbie
    Replies: 12
    Last Post: 1st December 2010, 23:45
  2. Sorting
    By bismitapadhy in forum Qt Programming
    Replies: 26
    Last Post: 30th January 2010, 17:59
  3. Sorting a qtablewidget......
    By reshma in forum Qt Programming
    Replies: 8
    Last Post: 23rd March 2009, 15:34
  4. Customizing Sorting
    By delalaym in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2009, 01:22
  5. [QT4] QTreeView, QAbstractItemModel and sorting
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th March 2006, 21:16

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.