QStandardItemModel performance [SOLVED]
-
Hello,
I need to show data of a server in a QTreeView.
A thread launch a function who use a QList<QStandardItem *> for store data.
When the thread finished I put the data in the QStandardItemModel.
I have no problem to store the data in the QList but when I want to show them in the QTreeView it takes arround 20 seconds because I have arround 3000 items.in the .cpp when the thread finished
@void ihm_test::f_fin_thread()
{
QList<QStandardItem *>::iterator qlIterator=qlListeItems.begin();
while(qlIterateur!=qlListeItems.end())
{
qsModel->appendRow(*qlIterateur);
qlIterateur++;
}
}@in the constructor
@qsModel = new QStandardItemModel;
ui->treeViewBDD->setModel(qsModel);@In another .cpp I do
@qlListeItems.push_back(new QStandardItem(this->nom()));@How can it take less time ?
Thank for your answer
ps: sorry for my poor english
-
Thank you for your answer,
No I don't try other view but I think it's not the problem.
I put a break point before showing the model and it run fast.
I think the probleme it's here:
@qsModel->appendRow(*qlIterateur);@I tried QStandardItemModel::appendColumn and he does the same.
-
I have solved my problem.
The problem was the model are being set to the QTreeView in the constructor and I insert data in the model in another function.The solution is to clean the model of the QTreeView before changing data of the model.
Before editing data of qsModel
@ui->treeViewBDD->setModel(new QStandardItemModel());@After
@ui->treeViewBDD->setModel(qsModel);@Thanks !