Results 1 to 6 of 6

Thread: About QAbstractProxyModel::sort(...) method

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: About QAbstractProxyModel::sort(...) method

    Your model decides which field it maps into which column.

    That's what models do: they provide an abstract interface to data. their main job is to define what a row means and what a column means in terms of the data they are working on.

    Cheers,
    You're absolutely right but it would be much better if there is a sort method which takes a Role as a parameter.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: About QAbstractProxyModel::sort(...) method

    You mean like calling QSortFilterProxyModel::setSortRole() before sorting?

    You are, of course, quite welcome to subclass either the model or the proxy to reimplement sort() however you want. The function is virtual for a reason.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: About QAbstractProxyModel::sort(...) method

    Quote Originally Posted by zgulser View Post
    You're absolutely right but it would be much better if there is a sort method which takes a Role as a parameter.
    It would still need a column.

    The model can use whatever it wants for sorting, the sorting key doesn't even have to be accessible through a role.
    Of course the model can always allow to set a sorting role as additional information if a single column can be sorted differently depending on what role one is using.

    Cheers,
    _

Similar Threads

  1. Custom QAbstractProxyModel
    By alizadeh91 in forum Qt Programming
    Replies: 16
    Last Post: 5th January 2013, 23:52
  2. Calling a method from a non-member method
    By AndresBarbaRoja in forum Newbie
    Replies: 5
    Last Post: 19th March 2011, 10:38
  3. Replies: 1
    Last Post: 25th November 2010, 11:37
  4. How to sort a Qlist AND get a sort key?
    By agerlach in forum Qt Programming
    Replies: 3
    Last Post: 26th July 2010, 18:44
  5. Help with QAbstractProxyModel
    By killerwookie99 in forum Qt Programming
    Replies: 9
    Last Post: 12th September 2008, 22:13

Tags for this Thread

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.