FluentUI/example/qml-Qt6/page/T_ComboBox.qml

105 lines
2.5 KiB
QML
Raw Normal View History

2023-08-24 15:50:37 +08:00
import QtQuick
import QtQuick.Layouts
import QtQuick.Window
import QtQuick.Controls
import FluentUI
2024-01-25 17:26:50 +08:00
import "../component"
2023-08-24 15:50:37 +08:00
FluScrollablePage{
2024-03-09 15:35:48 +08:00
title: qsTr("ComboBox")
2023-08-24 15:50:37 +08:00
FluArea{
Layout.fillWidth: true
height: 80
paddings: 5
Layout.topMargin: 20
Column{
spacing: 5
anchors.verticalCenter: parent.verticalCenter
FluText{
text: "editable=false"
x:10
}
FluComboBox {
model: ListModel {
id: model_1
ListElement { text: "Banana" }
ListElement { text: "Apple" }
ListElement { text: "Coconut" }
}
}
}
}
2024-03-08 10:29:38 +08:00
FluArea {
Layout.fillWidth: true
height: 80
paddings: 5
Layout.topMargin: 20
Column{
spacing: 5
anchors.verticalCenter: parent.verticalCenter
FluText{
text: "disabled=true"
x:10
}
FluComboBox {
disabled: true
model: ListModel {
id: model_2
ListElement { text: "Banana" }
ListElement { text: "Apple" }
ListElement { text: "Coconut" }
}
}
}
}
2023-08-24 15:50:37 +08:00
FluArea{
Layout.fillWidth: true
height: 80
paddings: 10
Layout.topMargin: 20
Column{
spacing: 5
anchors.verticalCenter: parent.verticalCenter
FluText{
text: "editable=true"
x:5
}
FluComboBox {
editable: true
model: ListModel {
2024-03-08 10:29:38 +08:00
id: model_3
2023-08-24 15:50:37 +08:00
ListElement { text: "Banana" }
ListElement { text: "Apple" }
ListElement { text: "Coconut" }
}
onAccepted: {
if (find(editText) === -1)
2024-03-08 10:29:38 +08:00
model_3.append({text: editText})
2023-08-24 15:50:37 +08:00
}
}
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluComboBox{
editable: true
model: ListModel {
id: model
ListElement { text: "Banana" }
ListElement { text: "Apple" }
ListElement { text: "Coconut" }
}
onAccepted: {
if (find(editText) === -1)
model.append({text: editText})
}
}'
}
}