Binding a TextField to the current TableView item [solved]
-
Hi,
I'm using the QML desktop-components and want to bind the currently selected row of a TableView to a TextField, so I'm using this code:
@TextField {
text: mymodel.get(tableview.currentIndex).myproperty
}@If I change the current item in the TableView, the value of the TextField changes, as expected.
But if I modify the TextField, the model data does not change! In general, I'd think, that this is possible, because QML uses bindings.
I think the problem is using a getter here.Would it be possible to modify this code to something like
@
text: mymodel[tableview.currentIndex].myproperty
@
to create a bidirectional binding: so that the model is modified, if the value of the TextField is changed? -
@text: mymodel.get(tableview.currentIndex).myproperty@
This creates one directional binding. When ever value of right side expressing changes, value of left side variable is updated with new value. But the other way is not true. When ever text changes, it does not updated model data.
http://doc.qt.nokia.com/4.7-snapshot/propertybinding.html