【发布时间】:2015-01-21 06:38:01
【问题描述】:
我想在我的项目中使用ComboBox 类型。是否可以更改下拉菜单的外观(颜色、形状、文本样式)或者我需要使用矩形、ListViews 和其他类型的组合?
以下代码应用了自定义,但没有为保持灰色的下拉菜单定义修改:
ComboBox {
currentIndex: 2
activeFocusOnPress: true
style: ComboBoxStyle {
id: comboBox
background: Rectangle {
id: rectCategory
radius: 5
border.width: 2
color: "#fff"
Image {
source: "pics/corner.png"
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.bottomMargin: 5
anchors.rightMargin: 5
}
}
label: Text {
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 15
font.family: "Courier"
font.capitalization: Font.SmallCaps
color: "black"
text: control.currentText
}
}
model: ListModel {
id: cbItems
ListElement { text: "Banana" }
ListElement { text: "Apple" }
ListElement { text: "Coconut" }
}
width: 200
}
【问题讨论】:
标签: c++ qt user-interface qml