Is there any way to get item class in QML
? I know about objectName
and id
etc. but it looks a bit strange and not so comfortable. This is what i need:
ComboBox {
id: comboBox
}
TextField {
id: textField
}
function getValue(item) {
switch(item.???) { //what property can I use here?
case 'ComboBox':
return item.model.get(item.currentIndex).value;
case 'TextField':
return item.text;
}
}
using objectName
as described in lots of articles over the Internet might be ambiguous and excessive, for example:
ComboBox {
id: comboBox
objectName: "ComboBox"
}
TextField {
id: textField
objectName: "ComboBox" /// oops!!
}
function getValue(item) {
switch(item.objectName) {
case 'ComboBox':
return item.model.get(item.currentIndex).value;
case 'TextField':
return item.text;
}
}