Results 1 to 13 of 13

Thread: QTableView sorting

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    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: QTableView sorting

    Quote Originally Posted by realdarkman71 View Post
    ...this doesn't work unfortunately, the constructor allows no numbers!

    Qt Code:
    1. QStandardItem::QStandardItem ( const QIcon & icon, const QString & text )
    2. QStandardItem::QStandardItem ( int rows, int columns = 1 )
    To copy to clipboard, switch view to plain text mode 
    So create the item with the default constructor and then use QStandardItem::setData() to set a QVariant of type QVariant::Int (or Uint, LongLong etc.) as the data for the Qt::DisplayRole. Alternatively, set the integer data on the EditRole and use setSortRole on the model to set the sort role to the EditRole.

  2. The following user says thank you to ChrisW67 for this useful post:

    realdarkman71 (1st December 2010)

Similar Threads

  1. QTableView sorting
    By gabriels in forum Qt Programming
    Replies: 11
    Last Post: 6th October 2010, 17:13
  2. QTableView sorting problem
    By noktus in forum Newbie
    Replies: 11
    Last Post: 23rd April 2008, 10:20
  3. QSqlTableModel and QTableView and sorting
    By JeanC in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2008, 13:22
  4. QTableView sorting
    By Bojan in forum Newbie
    Replies: 2
    Last Post: 28th September 2006, 08:11
  5. Sorting QTableView
    By Jimmy2775 in forum Qt Programming
    Replies: 7
    Last Post: 9th February 2006, 16:47

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.