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

QListView repeatedly calls sizeHint for all items causing significant slow downs for huge lists

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Fixed
    • Not Evaluated
    • None
    • 6.3.0
    • None
    • All

    Description

      When using a QStyledItemDelegate with a QListView, the sizeHint call is issued for every single item in the list, causing slowdowns when the list is large.

      In my test example, I have about 750.000 item.

      doBatchedItemLayout calls itemSize 739686 times,  The Visual Studio grab shows the state.  items is empty and info.last is 739686.

       It looks like mouse movement can cause a call to doBatchedItemLayout to be made as well.

      sizeHint is about 35% of my performance profile, so reducing the number of calls would help a great deal. 

       

       

      bool QIconModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
      {
          if (info.last >= items.count()) {
              //first we create the items
              QStyleOptionViewItem option;
              initViewItemOption(&option);
              for (int row = items.count(); row <= info.last; ++row) {
                  QSize size = itemSize(option, modelIndex(row));
                  QListViewItem item(QRect(0, 0, size.width(), size.height()), row); // default pos
                  items.append(item);
              }
              doDynamicLayout(info);
          }
          return (batchStartRow > max); // done
      }
      
      

       

       list of about 100,000 items.  

       

      Attachments

        1. image-2022-11-16-23-05-46-134.png
          324 kB
          Doug Rogers
        2. image-2022-11-16-23-28-39-572.png
          303 kB
          Doug Rogers
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            lagocs Laszlo Agocs
            doug_rogers Doug Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes