QSortFilterProxyModel not updating View
As the title says I have QTableViews with QFilteProxyModels.But when any change is made to the database,the view is not updated.
Here is my code
Code:
void Factory::setupDealersTabModel()
{
QString query
= "select name,organization,debt from dealers";
if(!q.exec(query)){
}
model->setQuery(query);
//test code
dealer_proxy_model->setDynamicSortFilter(true);
//set model
ui->dealers_tableview->setModel(dealer_proxy_model);
dealer_proxy_model->setSourceModel(model);
}
void Factory::setupSuppliersTabModel()
{
QString query
= "select name,organization,balance from supplier";
if(!q.exec(query)){
}
model->setQuery(query);
//set proxy
supplier_proxy_model->setDynamicSortFilter(true);
//set model
supplier_proxy_model->setSourceModel(model);
ui->suppliers_tableview->setModel(supplier_proxy_model);
}
---
Re: QSortFilterProxyModel not updating View
Hi, you don't show how you're updating your database. The model must inform the view that the data has changed. You don't seem to be subclassing QSqlQueryModel and from the docs, I see the following:
Quote:
The model is read-only by default. To make it read-write, you must subclass it and reimplement setData() and flags(). Another option is to use QSqlTableModel, which provides a read-write model based on a single database table.
So, can you elaborate on how your model is changed?