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

QHeaderView creates fake entries on restoreState

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.2
    • Widgets: Itemviews
    • None
    • Windows 10
    • Windows

    Description

      To reproduce:

      1. Enable the vertical header in QTableView
      2. Add several rows into the model
      3. Save header's state
      4. Create a new QTableView with an enabled vertical header, but without any data
      5. Restore the saved header state

      Actual result: header generates empty rows, though the model doesn't contain them.
      E.g.

      QTableView::reset doesn't help.
      Most probably the issue is in here

      void QHeaderView::initializeSections(int start, int end)
      {
          Q_D(QHeaderView);
      
          Q_ASSERT(start >= 0);
          Q_ASSERT(end >= 0);
      
          d->invalidateCachedSizeHint();
          int oldCount = d->sectionCount();
      
          if (end + 1 < d->sectionCount()) { // <===
              int newCount = end + 1;
              d->removeSectionsFromSectionItems(newCount, d->sectionCount() - 1);
              if (!d->hiddenSectionSize.isEmpty()) {
      ...
      

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            anmy Anton Mykhailov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes