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

QTreeWidget keyPressEvent: Asterisk can be very slow

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.12.0 Alpha
    • 4.8.6, 5.11
    • Widgets: Itemviews
    • None
    • all
    • 0e2dae902b316a40a1d861198da55118d2155964

    Description

      I have noticed the following performance issue with QTreeWidget:
      when asterisk is pressed and at least one child of current item is visible, interface freezes for several seconds (for large tree);
      but if no child of current item is visible (item is collapsed), expanding all nodes after pressing asterisk is instantaneous.

      Simple workaround for asterisk performance issue in user code:

      // class TreeWidget : public QTreeWidget
      void TreeWidget::keyPressEvent(QKeyEvent * const event)
      {
          if (event->key() == Qt::Key_Asterisk)
              currentItem()->setExpanded(false);
          QTreeView::keyPressEvent(event);
      }
      

      I would guess that the following simple workaround is possible in Qt code:

      void QTreeView::keyPressEvent(QKeyEvent *event)
      { ...
          case Qt::Key_Asterisk: {
      [+]     collapse(current);
              ...
      }
      

      EDIT: this issue is only present with

      tree->header()->setStretchLastSection(false);
      

      Attachments

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

        Activity

          People

            chehrlic Christian Ehrlicher
            vedg Igor Kushnir
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes