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

HorizontalHeaderView does not call headerData() when subclassing QAbstractItemModel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • None
    • 6.7.2
    • Quick: Controls 2
    • None
    • Win11 MSVC
    • Windows

    Description

      When directly subclassing QAbstractItemModel, HorizontalHeaderView does not call headerData(). However, by subclassing QAbstractTableModel, it can fetch data correctly.

      I quote from the documentation: "If you assign a model that is a QAbstractItemModel, its header data will be used. Otherwise, the data in the model will be used directly (for instance, if you assign a model that's simply an array of strings)."

      Here is the result when subclassing from QAbstractItemModel:

      And the results when inheriting from QAbstractTableModel:

      Please download the attachment and replicate the problem.

      Attachments

        1. headerView_demo-1.zip
          2 kB
          yi wang
        2. image-2024-08-30-17-06-43-039.png
          5 kB
          yi wang
        3. image-2024-08-30-17-07-04-331.png
          6 kB
          yi wang

        Issue Links

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

          Activity

            People

              richard Richard Moe Gustavsen
              warindy yi wang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes