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

Delegates' updates to ItemView models are not reflected in the public "model" property

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.9.0
    • None

    Description

      Consider:

      import QtQuick
      Window {
          visible: true
          ListView {
              id: view
              anchors.fill: parent
              model: [
                  {greeting: "Hello", amount: 1},
                  {greeting: "Goodbye", amount: 3},
                  {greeting: "Cheers", amount: 4}
              ]
              delegate: Row {
                  required property QtObject model
                  TextInput {
                      text: model.greeting
                      onEditingFinished: {
                          model.greeting = text
                          console.log(view.model[0].greeting)
                      }
                  }
                  Text {
                      text: ", World, " + model.greeting + ", " + model.amount + " times!"
                  }
              }
          }
      }
      

      This still outputs "Hello" even if you change the greeting in the first row via the TextInput. We do have an up to date QVariantList in QQmlListAccessor::d, but ListView does not expose it. Rather, it exposes its own copy of the list that it keeps in QQuickItemViewPrivate::modelVariant.

      Note that fixing this also involves sending the relevant signals when changing model data.

      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
            ulherman Ulf Hermann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes