QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(parent); proxyModel->setSourceModel(sourceModel); proxyModel->setDynamicSortFilter(true);
QStandardItemModel *model = new QStandardItemModel(); QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(model); proxyModel->setDynamicSortFilter(true); tableView->setModel(proxyModel);In this example, a QStandardItemModel instance is created and then set as the source model for the QSortFilterProxyModel instance. Dynamic sorting and filtering is enabled on the proxy model. The proxy model is then set as the model for a QTableView instance. Package library: Qt.