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

Clarify the snippet about Editing Cells in a TableView

    XMLWordPrintable

Details

    • All
    • 9ae58a8e6 (dev), 9930959ac (6.8), 79d64c8e5 (6.7), 6d602b166 (tqtc/lts-6.5)

    Description

      https://doc.qt.io/qt-6/qml-qtquick-tableview.html#editing-cells states that
      TableView.onCommit:

      {display = text// 'display = text' is short-hand for:// let index = TableView.view.index(row, column)// TableView.view.model.setData(index, text, Qt.DisplayRole)}

      This may be true in case the model is an QAbstractItemModel https://doc.qt.io/qt-6/qabstractitemmodel.html#setData. But in the snippet example a TableModel is used so the signature for setData() is different: https://doc.qt.io/qt-6/qml-qt-labs-qmlmodels-tablemodel.html#setData-method

      The code should be:

      TableView.view.model.setData(index, "display", text)

      Or better still the TableModel's setData() function should maybe have the same signature than QAbstractItemModel's... 

       

      Attachments

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

        Activity

          People

            lexcaz Alexei Cazacov
            pijaouen Pierre Jaouen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes