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

HorizontalHeaderView does not call headerData() when subclassing QAbstractItemModel

XMLWordPrintable

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

      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.

        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
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes