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

QML needs a TwoWay binding like XAML has, to support Model View ViewModel correctly

    XMLWordPrintable

Details

    Description

      When a developer wants to apply scenario's were a ViewModel and a View heavily interact with each other on a piece of state (for example the text field of a TextInput), a TwoWay binding would be much more useful than what we have now in QML.

      For example:

      TextInput {
       id: container
       MyTextInputViewModel viewModel
      
        onTextChanged {
         viewModel.inputText = container.text
        }
      
        Connections
        {
          target: viewModel
           onInputTextChanged: container.text = viewModel.inputText
        }
      }
      
      

      In XAML something similar is not only much more simple, but also much more standardized. This standardization makes that XAML developers will not make the mistake of letting state get owned by the View.qml all over the place (which in the MVVM world should be in the ViewModel instead).

      While many Qt experts try to explain the world that writing all business logic in the View.qml as JavaScripts ain't a good idea, the support in QML for bindings is however also not 100% sufficient to do full Model View ViewModel techniques.

      Take a look at how this is done in XAML here:

      https://docs.microsoft.com/en-us/dotnet/api/system.windows.data.bindingmode?view=netframework-4.7.2#System_Windows_Data_BindingMode_TwoWay

      Attachments

        Issue Links

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

          Activity

            People

              shausman Simon Hausmann
              pvanhoof Philip Van Hoof
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes