QML
에 항목 클래스를 가져 오는 방법이 있습니까? 나는 objectName
과 id
등을 알고 있지만 조금 이상하고 너무 편안하지 않습니다.QML에서 기본 클래스를 얻는 방법?
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;
}
}
objectName
를 사용하여 인터넷 모호한 과도한 수 있습니다 이상, 예를 들어, 기사의 많은에 설명 된대로 :
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;
}
}
이러한 이름은 구성 요소가 선언 된 파일의 이름 일 뿐이므로 구문 분석 후 이러한 종류의 정보가 지워질 가능성이 큽니다. ... – Kakadu