ComboBox model avalable inside delegate but not in contentItem
Solved
QML and Qt Quick
-
Hi,
Can please someone tell me how i should reference the text of current index in the contentItem ?ComboBox { id: control model: ListModel { id: cbItems ListElement { tx: "Fr"; flg: "img/flagFr.png" } ListElement { tx: "En"; flg: "img/flagBri.png" } } // displayText: tx // ReferenceError tx delegate: ItemDelegate { property alias curr:lab // tryed with alias width: control.width contentItem:Rectangle{ anchors.fill: parent Row{ anchors.fill: parent Image { id: flag source: flg } Text { id:lab text:tx } } } highlighted: control.highlightedIndex == index } indicator: Canvas {...} contentItem: Text { text: /* show the selected index text*/ font: control.font color: "black" } background: Rectangle { } popup: Popup { contentItem: ListView {} } }
-
Hi @LeLev , have you tried with this:-
control.model.get(control.currentIndex).tx
-
@Shrinidhi-Upadhyaya thank you very much it worked