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

Custom roles do not work in HorizontalHeaderView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.2
    • Quick: Controls 2
    • None
    • Python 3.8.6
      PySide6==6.4.2
    • Windows

    Description

      Binding a property of the delegate of a `HorizontalHeaderView` to a custom role of a `QAbstractTableModel` doesn't successfully fetch the relevant data from `headerData()`. 

       

      Note that when running the example below:

      • Header text says "This is display table data"
      • Table text says "This is custom table data"
      • Terminal shows `Display header data requested`
      • Terminal shows `Custom table data requested`

      To reproduce bug:

      • Change the line marked `// BUG HERE` to `text: model.my_custom_role`.

      Expected behaviour:

      • Header text shows "This is custom data", just like the table itself. 
      • Terminal shows `Custom header data requested`

      Actual behaviour:

      • Header text blank
      • Error message in terminal: "Unable to assign [undefined] to QString"
      • Terminal does not show `Custom header data requested`

      Attachments

        1. b.py
          1 kB
        2. B.qml
          0.8 kB

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            jamiesanden-refeyn Jamie van der Sanden
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: