[英]QML Combobox Width of Elements
The QML controls are fully customizable, so you can create your own view, for example: QML 控件是完全可自定义的,因此您可以创建自己的视图,例如:
ComboBox {
id: control
anchors.centerIn: parent
model: ["First", "Second", "Third"]
background: Rectangle {
color: "lightgrey"
border {width: 1; color: "grey"}
implicitWidth: 50
implicitHeight: 30
}
contentItem: Label {
text: control.currentText.charAt(0)
font: control.font
padding: 4
verticalAlignment: Text.AlignVCenter
}
popup: Popup {
y: control.height - 1
width: 200
implicitHeight: contentItem.implicitHeight
contentItem: ListView {
clip: true
implicitHeight: contentHeight
model: control.popup.visible ? control.delegateModel : null
currentIndex: control.highlightedIndex
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.