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

QHeaderView creates fake entries on restoreState

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: Widgets: Itemviews
    • Labels:
      None
    • Environment:
      Windows 10
    • Platform/s:
      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

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

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes