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

When a model.role value is changed in QML, update the corresponding value in the model

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P2: Important
    • 5.0.0
    • 4.7.0, 5.0.0
    • None
    • Qt (kinetic-declarative) - git from 3. feb. 2010
      Ubuntu 9.10

    Description

      When a C++ data model (like a derived class of QAbstractListModel) is exposed to QML via a context property, and that model is editable, the different properties of an item (that are accessible to the delegate by model.someproperty) should be writeable, too.
      I am currently unable to find a simple method to edit that kind of data except emitting a signal from the root component and catching that in C++ and then setting the data there.

      For example

      //assigning someModel an editable derived class of QAbstractListModel
      contx->setContextProperty("someModel", someModel);   
      
      // in QML
      ListView {
        id: someListView
        delegate: someDelegate
        model: someModel
      }
      
      Component {
        id: someDelegate
        ...
        function saveData() {
          model.someproperty = someNewValue;
          model.anotherproperty = anotherNewValue;
        }
        ...
      }
      

      I hope it's clear what I mean...
      If thats not the way to go, please update the documentation with the "right" method.

      Attachments

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

        Activity

          People

            denexter Andrew den Exter (closed Nokia identity) (Inactive)
            raven24 Florian Staudacher
            Votes:
            18 Vote for this issue
            Watchers:
            27 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes