Results 1 to 2 of 2

Thread: QSortFilterProxyModel not updating

  1. #1
    Join Date
    Mar 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSortFilterProxyModel not updating

    Hello,

    I'm using a QSortFilterProxyModel in order to keep the rows of a tableview sorted by the values in the column 'index'.
    When i change a value in the column 'index', the tableview is updated accordingly but the proxy model doesn't re-apply the sorting automatically.
    However when i sort the column 'index' manually by clicking on its header once, then the proxy model updates itself for every future modification of values in the column, as i would like it to do.
    So my question is : what happens when i click on the header of the column that i don't do programatically ?

    Here is my code :

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
    2. {
    3. ui->setupUi(this);
    4.  
    5. this->proxyModel = new QSortFilterProxyModel();
    6.  
    7. proxyModel->setSourceModel(model);
    8. proxyModel->setDynamicSortFilter(true);
    9. proxyModel->sort(0, Qt::AscendingOrder);
    10.  
    11. ui->tableView->setModel(proxyModel);
    12. ui->tableView->sortByColumn(0, Qt::AscendingOrder);
    13. }
    To copy to clipboard, switch view to plain text mode 

    Thank you.

  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: QSortFilterProxyModel not updating


Similar Threads

  1. How to fasten QSortFilterProxyModel ?
    By Guilo in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2010, 14:34
  2. Problems with QSortFilterProxyModel
    By Nefastious in forum Newbie
    Replies: 10
    Last Post: 31st October 2009, 19:51
  3. QSortfilterProxyModel and Treeview
    By hunsrus in forum Qt Programming
    Replies: 0
    Last Post: 27th March 2009, 13:36
  4. Using QSortFilterProxyModel
    By Jennie Bystrom in forum Qt Programming
    Replies: 3
    Last Post: 6th December 2007, 11:28
  5. QSortFilterProxyModel
    By evgenM in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2007, 12:53

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.