Qt5 use QSortFilterProxyModel slow in use setFilterFixedString()
this is my first time use this blog,I am not good at English and I'm not familiar with the posting rules.:)
I use Qt 5.15.3 centOs 7?use Qt Model view and QSortFilterProxModel filter data show?but use this is so slow.
my test add source model item 100w,add changed all checkbox function and filter by name fucntion
in my computer ,changed all checkbox use about 0.1s,filter name use about 12s.filter is so slow,i need this function better.
this is like my code but not real use? please give me some advice.
Code:
//init
QSortFilterProxModel * filterModel = new QSortFilterProxModel (this);
int num = 1000000;
for(int i =0; i< num;++i)
{
item->setCheckable(true);
item->setCheckState(Qt::Checked);
model->appendRow(item);
}
filterModel->setSourceModel(model);
filterModel->setDynamicSortFilter(false);
listView->setModel(filterModel);
//function changed all checkbox?0.1s
void changedCheckbox(bool isChecked)
{
this->beginResetModel();
for(int i =0; i < rowCount();i++?
{
QStandardItem* item = model->item(i,0);
item->setCheckState(isCheck ? Qt::checked : Qt::Unchecked);
}
this->endresetModel();
}
fucntion filter by name ?12s
void changedFilter(QString name)
{
filterModel->setFilterFixedString(name);
}
Re: Qt5 use QSortFilterProxyModel slow in use setFilterFixedString()
I would try without beginResetModel/endResetModel. Furthermore, QStandardItemModel will never be very performant.