Results 1 to 3 of 3

Thread: qtableview sort question?

  1. #1
    Join Date
    Dec 2008
    Location
    chinese
    Posts
    47
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default qtableview sort question?

    i need sort by columen of qtableview,but qtableview sort by char ,but i need sory by int,
    for example:
    a columen data is : 1, 2, 10 , it is 1,10,2 if sort by char,but i need 1,2,10 .
    can somebody holp me? thanks

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qtableview sort question?

    Are you using QSortFilterProxyModel ?
    If yes you need to override QSortFilterProxyModel::lessThan ..

    if you are not using QSortFilterProxyModel you must be using some model...
    You will need to override QAbstractItemModel::sort.

    But it will be preferable that you use QSortFilterProxyModel and override the lessThan function. You wont have to alter your model

  3. #3
    Join Date
    Dec 2008
    Location
    chinese
    Posts
    47
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qtableview sort question?

    Quote Originally Posted by aamer4yu View Post
    Are you using QSortFilterProxyModel ?
    If yes you need to override QSortFilterProxyModel::lessThan ..

    if you are not using QSortFilterProxyModel you must be using some model...
    You will need to override QAbstractItemModel::sort.

    But it will be preferable that you use QSortFilterProxyModel and override the lessThan function. You wont have to alter your model
    thank you very much,i am success follow your way .
    but i run into other question : i want some column header do't click,but i get just headerview ,do't make some column header do't click.
    hope you help me,thanks

Similar Threads

  1. QTableView populating question
    By onefootswill in forum Newbie
    Replies: 8
    Last Post: 7th August 2008, 22:29
  2. Updating a data in QTableView question
    By MarkoSan in forum Qt Programming
    Replies: 5
    Last Post: 6th June 2008, 11:45
  3. QTableView and its Scrollbar question
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 28th May 2008, 14:23
  4. Question on QAbstractItemModel vs. QTableView
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2007, 07:29
  5. QTableView Question
    By kandalf in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2007, 18: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.