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 :
{
ui->setupUi(this);
proxyModel->setSourceModel(model);
proxyModel->setDynamicSortFilter(true);
proxyModel->sort(0, Qt::AscendingOrder);
ui->tableView->setModel(proxyModel);
ui->tableView->sortByColumn(0, Qt::AscendingOrder);
}
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->proxyModel = new QSortFilterProxyModel();
proxyModel->setSourceModel(model);
proxyModel->setDynamicSortFilter(true);
proxyModel->sort(0, Qt::AscendingOrder);
ui->tableView->setModel(proxyModel);
ui->tableView->sortByColumn(0, Qt::AscendingOrder);
}
To copy to clipboard, switch view to plain text mode
Thank you.
Bookmarks