retreive combobox data from repeater
-
Hello,
I would like to know if it's possible to get data from each combobox if I use repeater.
using the code below, I have the desired result, 10 line combobox :
Column{ anchors.top:title.bottom anchors.topMargin: 8 Repeater{ id:comborepeater model:10 Rectangle{ id:rectdesc width:250 height:30 ComboBox { id: descriptionInput anchors.fill:parent editable:true textRole: "part" model: combopnModel style: ComboBoxStyle{ font { pixelSize: 18 } } } Text{ id:qtytitle anchors.left:descriptionInput.right anchors.top:descriptionInput.top anchors.leftMargin: 8 font.pixelSize: 18 text:"Qty" } TextField{ height:parent.height width:height*2 anchors.left:qtytitle.right anchors.top:descriptionInput.top anchors.leftMargin: 8 font.pixelSize: 18 } } } } } } ListModel { id: combopnModel } Component.onCompleted: { JS.comboboxpartnumberonly() }but what I have to do to get data for each?
thanks for your help
-
console.log(comborepeater.children[5].children[0].currentIndex)This will return your the current index of 6th combo box.
To make it simpler you can add your combobox as property to
rectdesccomponent, like this:Rectangle{ id:rectdesc width:250 height:30 property alias combobox: descriptionInput ComboBox { id: descriptionInput // then: console.log(comborepeater.children[5].combobox.currentIndex)