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

Make it easier to read and write model data outside of a delegate

    XMLWordPrintable

Details

    Description

      When in a delegate, it's easy to read (and have bindings to) and write model data:

      Slider {
          value: model.someValue
          onMoved: model.someValue = value
      }
      

      If you want to have an editor that is equivalent to a delegate but only shows the current item, it's less convenient:

      Slider {
          value: view.currentIndex !== -1 ? view.model.data(view.model.index(view.currentIndex, 0), Model.SomeValueRole) : 0
          onMoved: view.model.setData(view.model.index(view.currentIndex, 0), value, Model.SomeValueRole)
      }
      

      This assumes that you have an enum for the roles and that that enum is exposed to QML via Q_ENUM. It also doesn't react to changes to the current model data.

      We should make this more convenient somehow.

      Attachments

        Issue Links

          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
              mitch_curtis Mitch Curtis
              Votes:
              5 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes