Expose ListModel role as property
-
Hi everybody,
currently I'm working on an TextInput component with a binding to a model. Therefore I wanted to expose the responsible role for the ListItem as an property so that I can reuse the component multiple times.
Here the code snippets (only relevant stuff, model is named "myListModel")
MyInput.qml:
@import QtQuick 1.1Item {
property variant modelRole: xval // also with string this doesn't workTextInput { text: myListModel.get(randomId...).modelRole }
}
@MAIN:
@import QtQuick 1.1
Rectangle {
id: rootMyInput { modelRole: xval } MyInput { modelRole: yval } MyInput { modelRole: anotherrole }
}
@with the string as property I get
@Unable to assign [undefined] to QString text (in myTextInput.qml on the line of the text assignment)@
and without the string (written like a variable see example above) I get additionally:
@Reference Error: Can't find variable: xval (in myTextInput.qml on the line of definition of the property)@
I found already something that worked with a model: http://comments.gmane.org/gmane.comp.lib.qt.qml/1778 but there is nothing about exposing a role.
I think the main problem is the type of the property, but what is the appropiate property type for this case?
Best regards
Florian