带节的QtQuick2组合框
我希望在组合框中具有与ListView()相同的节功能 但是我在组合框里找不到这样的东西带节的QtQuick2组合框,qt,combobox,qml,qtquick2,qtquickcontrols2,Qt,Combobox,Qml,Qtquick2,Qtquickcontrols2,我希望在组合框中具有与ListView()相同的节功能 但是我在组合框里找不到这样的东西 这可能吗?为了在组合框中具有与列表视图相同的部分功能,您只需在组合框中包含列表视图 您基本上可以自定义所有Qt Quick Controls 2,下面是组合框的一个示例: 在您的情况下,您需要自定义弹出窗口属性,以包含启用了节的列表视图 我写了一个例子: ComboBox { id: control width: 200 model : ["Albert Dupontel","Ant
这可能吗?为了在
组合框
中具有与列表视图
相同的部分功能,您只需在组合框
中包含列表视图
您基本上可以自定义所有Qt Quick Controls 2,下面是组合框的一个示例:
在您的情况下,您需要自定义弹出窗口
属性,以包含启用了节的列表视图
我写了一个例子:
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 { }
}
}
}
它呈现为这样:Qt Quick Controls 1或2?我现在只使用2.0,我不确定是否可以混合使用1.0和2.0。好的,我添加了标记。如果导入为:import QtQuick.Controls 1.4为QQC1
,然后像这样使用:qqqc1.ComboBox
,则可以混合使用它们。这在这里并不重要,因为使用QQC2可以更轻松地实现您想要的功能。