Assigning an id in the delegate component
-
Hello, I want to set the id of the elements that are in delegate, so that later I can access the button signals in Timer. Please tell me how to do this
Timer { interval: 20 running: zoomminus.pressed || zoomplus.pressed || focusfar.pressed || focusnear.pressed // buttons id repeat: true onTriggered: { if (zoomminus.pressed) { nit300.upperFOV() } else if (zoomplus.pressed) { nit300.lowerFOV() } else if (focusfar.pressed) { nit300.focus++; } else if (focusnear.pressed) { nit300.focus--; } } } // Connections { // target: nit300 // } GridView { id:grid anchors.fill: parent property var actions: { "Фокус Far" : function () {print("far")}, //todo; "Фокус Near" : function () {print("Near")}, //todo; "Автофокус" : function () {nit300.focusAuto()}, "Зум+" : function () {print("Зум+")}, //todo; "Зум-" : function () {print("Зум-")}, //todo; "E-Zoom 2X" : function () {nit300.eZoomX2()}, "Время интегрирования+" : function () {nit300.upperIntegralTime()}, "Время интегрирования-" : function () {nit300.lowerIntegralTime()}, "Коррекция" : function () {nit300.correction()}, "Яркость+" : function () {nit300.upperBrightness()}, "Яркость-" : function () {nit300.lowerBrightness()}, "Контраст+" : function () {nit300.upperContrast()}, "Контраст-" : function () {nit300.lowerContrast()}, "Positive/Negative" : function () {nit300.polaritySwitch()}, "DDE--" : function () {nit300.edgeSharpenFast(false)}, "DDE++" : function () {nit300.edgeSharpenFast(true)}, "Self Check" : function () {nit300.testImage()}, } model: [ {name: "Фокус Far", type: "button"}, {name: "Фокус Near", type: "button"}, {name: "Автофокус", type: "button"}, {name: "f ' = " + nit300.focus/100.0 + " mm", type: "text"}, {name: "Зум+", type: "button"}, {name: "Зум-", type: "button"}, {name: "E-Zoom 2X", type: "button"}, {name: "FoV", type: "text"}, {name: "Время интегрирования+", type: "button"}, {name: "Время интегрирования-", type: "button"}, {name: "Коррекция", type: "button"}, {name: "Зум не норма", type: "text"}, {name: "Яркость+", type: "button"}, {name: "Яркость-", type: "button"}, {name: "Manual\nBrightContrast", type: "switch"}, {name: "Фокус не норма", type: "text"}, {name: "Контраст+", type: "button"}, {name: "Контраст-", type: "button"}, {name: "Positive/Negative", type: "button"}, {name: "Кулер не норма", type: "text"}, {name: "DDE--", type: "button"}, {name: "DDE++", type: "button"}, {name: "Self Check", type: "button"}, {name: "Температура не норма", type: "text"}, {name: "Ошибка связи", type: "text"}, {name: "ИК не норма", type: "text"}, {name: "Тестовый кадр", type: "text"}, {name: "Self Check Fail", type: "text"}, ] cellHeight: height / 7 cellWidth: width / 4 delegate: DelegateChooser { role: "type" DelegateChoice { roleValue: "button"; MyButton2 { width: grid.cellWidth height: grid.cellHeight text: modelData.name onClicked: grid.actions[modelData.name]() } } DelegateChoice { roleValue: "switch" MySwitch { width: grid.cellWidth height: grid.cellHeight text: modelData.name font.family: openSans.name onCheckedChanged: { nit300.brightnessContrastAuto(!checked) } } } DelegateChoice { roleValue: "text" Rectangle { width: grid.cellWidth height: grid.cellHeight color: root.darkBackgroundColor Text { // todo. Перенос текста на новую строку при изменении размера экрана. Сейчас текст залезает на соседнии элементы anchors.centerIn: parent text: modelData.name color: nit300.tempAlarm ? "orangered" : "mediumspringgreen" font.family: openSans.name } } } } }
-
Not supposed to this as delegates objects will be dynamically constructed & deleted. You should solve your problem in another way.
-
Not supposed to this as delegates objects will be dynamically constructed & deleted. You should solve your problem in another way.
@dheerendra can you please suggest a way to react to the signal of one of the elements in the ListView?
-
@dheerendra can you please suggest a way to react to the signal of one of the elements in the ListView?
function callMe(){
}Inside the delegate add the code. add Identity property of delegate as myId.
Component.onCompleted :{
myId.signal.connect(callMe);
} -
function callMe(){
}Inside the delegate add the code. add Identity property of delegate as myId.
Component.onCompleted :{
myId.signal.connect(callMe);
}@dheerendra Okay, but I need to handle pressing only certain buttons. Please tell me. I'll try on Monday, thanks
-