#qt #combobox #qml
#qt #выпадающий список #qml
Вопрос:
В моем макете очень маленький выпадающий список. Возможно ли увеличить размер элементов при создании выпадающего списка? Само поле должно оставаться небольшим.
Ответ №1:
Элементы управления 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
}
}
}