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.
//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);
}
//init
QListView* listView = new QListView?this??
QStandardItemModel* model = new QStandardItemModel(this);
QSortFilterProxModel * filterModel = new QSortFilterProxModel (this);
int num = 1000000;
for(int i =0; i< num;++i)
{
QstandardItem * item = new QStandardItem(QString("test%1).arg(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);
}
To copy to clipboard, switch view to plain text mode
Bookmarks