Details
-
Suggestion
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
None
-
None
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:
Attachments
Issue Links
- is duplicated by
-
QTBUG-19892 Allow "lazy" aliases to properties of objects created only later
- Closed
- relates to
-
QTBUG-30596 bi-directional or multi-sync variation of Binding
- Open