Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QStandardItemModel performance [SOLVED]
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
QList<QStandardItem *>::iterator qlIterator=qlListeItems.begin();
in the constructor
@qsModel = new QStandardItemModel;
In another .cpp I do
How can it take less time ?
Thank for your answer
ps: sorry for my poor english
bodzio131 last edited by
I'm not sure if 3000 items should cause performance problem for QTreeView, have you tried other views?
Are you sure that showing is the problem? what about inserting? Have you tried QStandardItemModel::appendColumn?
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:
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