Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QStandardItemModel performance [SOLVED]

QStandardItemModel performance [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kevin44115
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bodzio131
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kevin44115
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kevin44115
          wrote on last edited by
          #4

          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 !

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved