import QtQuick import QtQuick.Controls import QtQuick.Layouts Item { width: parent.width height: 30 property var currentIndex: -1 property var text: "" property var cbmodel: ListModel{} onCbmodelChanged: { if (cbmodel.count > 0) { selectItem(text) } } clip: true Rectangle{ width: 1 height: parent.height color: "#222" anchors.right: parent.right } Rectangle{ width: parent.width height: 1 color: "#222" anchors.bottom: parent.bottom } ComboBox { id: cmb currentIndex: find(parent.text) width: parent.width * 2 / 3 anchors.centerIn: parent textRole: "name" font.pixelSize: 15 model: cbmodel anchors.verticalCenter: parent.verticalCenter onActivated: { parent.text = model.get(currentIndex).name parent.currentIndex = currentIndex } } function selectItem(text) { cmb.currentIndex = findText(text) currentIndex = cmb.currentIndex } function findText(text) { for(var i = 0; i < cbmodel.count; i++) { if(cbmodel.get(i).name == text) { return i; } } return -1 } }