Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10988

unnecessary update in QAbstractItemView::doItemsLayout() causes performance issue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P2: Important
    • None
    • 4.7.0
    • Widgets: Itemviews
    • None

    Description

      QAbstractItemView::doItemsLayout() calling d->viewport()->update() causes a performance issue which can be reproduced with the following test case:

      #include <QApplication>
      #include <QTreeWidget>
      #include <QTime>
      #define NUM 3000
      
      class Work : public QObject
      {
      public:
              Work() :num(0)
              {
                      tree = new QTreeWidget;
                      tree->show();
                      time.start();
                      for( int i = 0; i < NUM; i++)
                      {
                              new QTreeWidgetItem(tree, QStringList(QString("item: %1").arg(i)));
                              qApp->processEvents();
                      }
                      qDebug("Finish. Time elapsed: %d ms", time.elapsed());
              }
      
      private:
              QTreeWidget *tree;
              int num;
              QTime time;
      };
      int main(int argc, char* argv[])
      {
              QApplication a(argc, argv);
              Work work;
              return a.exec();
      }
      
      

      By removing the d->viewport()->update() the performance promotes dramatically (26s to 3s in my test environment). And it doesn't seem to influence the ui updates (at least for this test case).

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            sanonymous Nokia Qt Support (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes