I have a ListModel which elements have information about a data type. I'm using this in a Repeater to show a label and a component according to the datatype, but I don't know how to change that TextField (in the case of "TEXT" datatype) with a; e.g. a button to call a file dialog in the case of "IMAGE"; or a TextField with a mask for double in the case I get datatype "REAL". How can I make this?
Here is my code:
Repeater {
id: r2
model: ListModel {
ListElement {
nombreCampo: "Name"
datoValor: "John Doe"
tipoDato: "TEXT"
}
ListElement {
nombreCampo: "Birth Date"
datoValor: "19910101"
tipoDato: "DATE"
}
ListElement {
nombreCampo: "Photo"
datoValor: "whatever.jpg"
tipoDato: "IMAGE"
}
ListElement {
nombreCampo: "Height"
datoValor: "1.55"
tipoDato: "REAL"
}
}
Text {
text: nombreCampo
}
// this would go well with "TEXT" but not with "DATE" (where I'd prefer a datepicker)
// or with "IMAGE" (where I'd prefer a button to call a file dialog).
// so this is the part where I need to generate it according to the case
TextField {
text: datoValor
placeholderText: nombreCampo
onTextChanged: {
r2.model.get( index ).datoValor = this.text;
}
}
}
Thanks in advance.