fee*_*0de 2 qt combobox qml qtquick2 qtquickcontrols2
我希望在ComViewBox中具有相同的部分功能,如ListView(截面ListView的示例).
但我在ComboBox中找不到这样的东西.
这甚至可能吗?
为了获得与a ListView中相同的部分功能ComboBox,您只需ListView在您的内容中包含一个ComboBox.
您可以自定义所有Qt Quick Controls 2,以下是一个示例ComboBox:https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-combobox
在您的情况下,您需要自定义popup属性以包括已ListView启用的部分.
我写了一个例子:
ComboBox {
id: control
width: 200
model : ["Albert Dupontel","Antoine Griezmann","Peter Sagan","Rodney Mullen","Serena Williams"]
popup: Popup {
y: control.height
width: control.width
implicitHeight: Math.min(contentItem.implicitHeight, 300)
padding: 0
contentItem: ListView {
clip: true
implicitHeight: contentHeight
model: control.popup.visible ? control.delegateModel : null
currentIndex: control.highlightedIndex
section.property: "modelData"
section.criteria: ViewSection.FirstCharacter
section.delegate: Label {
x: 10
text: section
}
ScrollIndicator.vertical: ScrollIndicator { }
}
}
}
Run Code Online (Sandbox Code Playgroud)
它呈现如下: 
| 归档时间: |
|
| 查看次数: |
299 次 |
| 最近记录: |