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

QHeaderView is very slow (unless it is used with only few data)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0
    • 4.7.2
    • Widgets: Itemviews
    • None
    • Windows and Linux + Qt 4.7.2 and probably any newer version of qt

    Description

      I have huge problems with performance (on many machines) with just 1000 rows and many calls to QHeaderView.

      (Below it is illustrated with 2 x 1 operation on a huge model)

      example.cpp
      #include <QTableView>
      #include <QStandardItemModel>
      #include <QHeaderView>
      #include <QApplication>
      #include <QElapsedTimer>
      #include <QDebug>
      
      const int rowcount = 50000; // Ok it is many, but a DB can easily hold 1.000.000 rows 
                                  // There are also gains for lesser rows - on slow machines (e.g boards or phones) this would also be very relevant
      
      int main(int argc, char *argv[])
      {
        QApplication app(argc, argv);
        QStandardItemModel m;
        m.setRowCount(rowcount);
        m.setColumnCount(19);
        QString tmp;
        for (int u=0;u<rowcount;++u)
        {
          tmp.setNum(u);
          m.setData(m.index(u,0),u);
        }
        QTableView v;
        v.setModel(&m);
        v.setGeometry(10,10,400,400);
        v.show();
        
        QHeaderView *h = v.verticalHeader(); 
        QElapsedTimer t;
        qDebug() << "Staring Timer.\n";  
        t.start();
        h->moveSection(0,rowcount-2);
        qint64 endtimer = t.elapsed();
        qDebug() << "Moving index time: " << endtimer << "\n";
        t.start();
        m.setRowCount(10);
        endtimer = t.elapsed();
        qDebug() << "Removing a lot of rows: " << endtimer << "\n";
      
        qDebug() << "Notice we are just doing ONE operation";
        qDebug() << "swapSction,resizeSection,hideSection are also a bit slow  ";
        qDebug() << "The above just makes ONE call to ONE operation. When I want to sort with swapSection or hide many it is horrible!";
        
        app.exec();
      }
      

      On a quite slow machine I got:
      Moving index time: 20710 (ms) (~20 s)
      Removing a lot of rows: 43134 (ms) (>40 s)

      The good 'news' is that I have patched the problem (and given further details): *https://qt.gitorious.org/qt/qt/merge_requests/1036*
      I have used this patch for 3 months without finding any problems with it. But I need it in Qt.

      On the same slow machine (patched)
      Moving index time: 5 (ms) (~instantly)
      Removing a lot of rows: 106 (ms) (~unnoticeable)

      Attachments

        Issue Links

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

          Activity

            People

              tlm Thorbjørn Martsum
              tlm Thorbjørn Martsum
              Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes