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

Delegate of a TableView fails to access data, if more than one data role is populated

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 6.8
    • None
    • All

    Description

      A column is supposed to populate two data roles:

      TableModelColumn { display: "index"; edit: "assignees" }
      

      Rows are populated by QJSValues:

       rows: [
              {
               index: 0,
               assignees: [ { value: "Volker"}, { value: "Matthias"} ]
              },
              {   
               index: 1,
               assignees: [ { value: "Paul"}, { value: "Eddy"} ]
              }
             ]
      

      Metadata is added correctly:

      qt.qml.tablemodel: - column 0:
      qt.qml.tablemodel:   - added metadata for built-in role "display" at column index 4: name="index" typeName="int" type=2
      qt.qml.tablemodel:   - added metadata for built-in role "edit" at column index 4: name="assignees" typeName="QVariantList" type=9
      

      ...but data can't be accessed in a delegate:

      DelegateChoice {
          column: 0
          delegate: ComboBox {
                id: comboBox
                model: model.edit
                currentIndex: model.display
            }
      }
      

      ...error message:

      Main.qml:142: TypeError: Cannot read property 'display' of undefined
      Main.qml:141: TypeError: Cannot read property 'edit' of undefined
      

      It works seemlessly, if only one data role is populated.

      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
            axelspoerl Axel Spoerl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes