Important: Please read the Qt Code of Conduct -

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();

    in the constructor
    @qsModel = new QStandardItemModel;

    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

  • 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
    @ui->treeViewBDD->setModel(new QStandardItemModel());@


    Thanks !

Log in to reply