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

Clarify the snippet about Editing Cells in a TableView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.5, 6.7
    • Documentation, Quick: Other
    • None
    • All

    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

            docteam Qt Documentation Team
            pijaouen Pierre Jaouen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes