I am trying to use QSortFilterProxyModel with QStandardItemmodel but filterAcceptedRows() is not updating the view.
The rows are correctly filetred in the function filterAcceptedRows() but the view is not updated. It is still displaying all the rows. Below you can find the code that i have already tried, could anybody tell me am i missing something here
This is the code in the QDialog.
m_modelApp = new QStandardItemModel();
m_proxyApp = new ProxyModelApp();
m_proxyApp->setSourceModel(m_modelApp);
m_lstApp->setModel(m_modelApp);
This is how i add data to the model.
QStandardItem *item1 = new QStandardItem();
QStandardItem *item2 = new QStandardItem();
QStandardItem *item3 = new QStandardItem();
QStandardItem *item4 = new QStandardItem();
QStandardItem *item5 = new QStandardItem();
QStandardItem *itemCheck = new QStandardItem();
item1->setData(l_sRefProduitSW,Qt::DisplayRole);
item2->setData("To Define",Qt::DisplayRole);
item3->setData(app.GetRefApp(),Qt::DisplayRole);
item4->setData(app.GetRefIdentApp(),Qt::DisplayRole);
item5->setData(app.GetRefFNRApp(),Qt::DisplayRole);
itemCheck->setCheckable(true);
if(m_xRefBe->GetListeAppBE().contains(app))
itemCheck->setCheckState(Qt::Checked);
else
itemCheck->setCheckState(Qt::Unchecked);
listItems<<itemCheck<<item1<<item2<<item3<<item4<<item5;
m_modelApp->appendRow(listItems);
One of the filter in the ProxyModelApp.
void ProxyModelApp::setRefLibApp(QString refLibApp){
if(m_refLibApp != refLibApp)
m_refLibApp = refLibApp;
invalidateFilter();
}
I would like to know, why after the successful filtering in the function filterAcceptedRows() does not update the view.
Thank you.
invalidateFilter()
– Simonm_listApp->setModel(m_proxyApp)
– Simonm_lstApp->setModel(m_modelApp);
tom_lstApp->setModel(m_proxyApp);
– eyllanesc