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

QmlTableModel complex types don't work as documented: Remove setters

    XMLWordPrintable

Details

    • 5
    • Foundation Sprint 134

    Description

      The interaction of complex data and custom setters/getters does not work as documented. This is documented only in the following snippet (https://doc.qt.io/qt-6/qml-qt-labs-qmlmodels-tablemodel.html#supported-row-data-structures):

      TableModel {
          TableModelColumn {
              display: function(modelIndex) { return rows[modelIndex.row][0].checked }
              setDisplay: function(modelIndex, cellData) {
                      rows[modelIndex.row][0].checked = cellData
                  }
          }
          // ...
      
          rows: [
              [
                  { checked: false, checkable: true },
                  { amount: 1 },
                  { fruitType: "Apple" },
                  { fruitName: "Granny Smith" },
                  { fruitPrice: 1.50 }
              ]
              // ...
          ]
      } 

       The getter is tested in tests/auto/qml/qqmltablemodel/data/complex.qml but the setter is not. A quick test showed that it would not work as documented. In fact, it is documented that it does not work to use the rows property to set data.

      There might be a way to make it work as shown here: https://codereview.qt-project.org/c/qt/qtdeclarative/+/662049 but it is rather hacky.

      Because it does not work and was never tested, it is safe to assume that no Qt user is using the custom setter functionality. Therefore we think it would be ok to remove the setters, which were never documented in depth anyway (https://doc.qt.io/qt-6/qml-qt-labs-qmlmodels-tablemodelcolumn.html). The custom getters and the complex data can stay as they seem to work and provide value.

      Improve the documentation of TableModelColumn when we're at it.

      Attachments

        For Gerrit Dashboard: QTBUG-138553
        # Subject Branch Project Status CR V

        Activity

          People

            mate Máté Barany
            matthias_rauter Matthias Rauter
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews