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

QHeaderView::ResizeToContents in QTableView makes hide very slow

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.0.0
    • 4.6.2, 4.7.0
    • None
    • Ubuntu 8.04
    • f86007175d7d9d592e9cf6499704ad4f17944ce4

    Description

      When using QHeaderView::ResizeToContents on a QTableView with a fairly large model, hiding the QTableView becomes very slow (which is very annoying if the view is part of a QTabWidget).

      The problem seems to be related to
      http://bugreports.qt.nokia.com/browse/QTBUG-5003
      though I have not tested it with QTreeWidget/QTreeView. Sample code (partially taken from the #5003) attached. With resize mode Stretch, hiding the view is very fast, with resize mode ResizeToContents it takes > 2 seconds.

      A backtrace shows that QHeaderView::resizeSections() is called on hide, which causes a call to QTableView::sizeHintForColumn(). There the lines
      if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport
      bottom = d->model->rowCount(d->root) - 1;
      cause all rows of the model to be checked, which is of course slow for large models (and seems kinda pointless if the view is not visible anyway...)

      Attachments

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

        Activity

          People

            liaqi Liang Qi
            b_mann Andreas Beckermann
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes