FluentUI/example/qml/page/T_ComboBox.qml

106 lines
2.7 KiB
QML
Raw Normal View History

2023-08-24 15:50:37 +08:00
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
2023-08-26 17:20:30 +08:00
import "../component"
2023-05-23 17:37:25 +08:00
FluScrollablePage{
2024-03-09 15:35:48 +08:00
title: qsTr("ComboBox")
2023-05-23 17:37:25 +08:00
2024-03-29 16:56:09 +08:00
FluFrame{
2023-05-23 17:37:25 +08:00
Layout.fillWidth: true
2024-03-29 16:23:16 +08:00
Layout.preferredHeight: 80
padding: 5
2023-05-23 17:37:25 +08:00
Column{
spacing: 5
anchors.verticalCenter: parent.verticalCenter
FluText{
text: qsTr("editable=false")
2023-05-23 17:37:25 +08:00
x:10
}
FluComboBox {
model: ListModel {
id: model_1
ListElement { text: qsTr("Banana") }
ListElement { text: qsTr("Apple") }
ListElement { text: qsTr("Coconut") }
2023-05-23 17:37:25 +08:00
}
}
}
}
2024-03-29 16:56:09 +08:00
FluFrame {
2024-03-18 22:26:22 +08:00
Layout.fillWidth: true
2024-03-29 16:23:16 +08:00
Layout.preferredHeight: 80
padding: 5
2024-03-18 22:26:22 +08:00
Layout.topMargin: 20
Column{
spacing: 5
anchors.verticalCenter: parent.verticalCenter
FluText{
text: qsTr("disabled=true")
2024-03-18 22:26:22 +08:00
x:10
}
FluComboBox {
disabled: true
model: ListModel {
id: model_2
ListElement { text: qsTr("Banana") }
ListElement { text: qsTr("Apple") }
ListElement { text: qsTr("Coconut") }
2024-03-18 22:26:22 +08:00
}
}
}
}
2024-03-29 16:56:09 +08:00
FluFrame{
2023-05-23 17:37:25 +08:00
Layout.fillWidth: true
height: 80
2024-03-29 16:23:16 +08:00
padding: 10
2023-05-23 17:37:25 +08:00
Layout.topMargin: 20
Column{
spacing: 5
anchors.verticalCenter: parent.verticalCenter
FluText{
text: qsTr("editable=true")
2023-05-23 17:37:25 +08:00
x:5
}
FluComboBox {
editable: true
model: ListModel {
2024-03-18 22:26:22 +08:00
id: model_3
ListElement { text: qsTr("Banana") }
ListElement { text: qsTr("Apple") }
ListElement { text: qsTr("Coconut") }
2023-05-23 17:37:25 +08:00
}
onAccepted: {
if (find(editText) === -1)
2024-03-18 22:26:22 +08:00
model_3.append({text: editText})
2023-05-23 17:37:25 +08:00
}
}
}
}
CodeExpander{
Layout.fillWidth: true
2024-03-29 16:23:16 +08:00
Layout.topMargin: -6
code:qsTr('FluComboBox{
2023-05-23 17:37:25 +08:00
editable: true
model: ListModel {
id: model
ListElement { text: "%1" }
ListElement { text: "%2" }
ListElement { text: "%3" }
2023-05-23 17:37:25 +08:00
}
onAccepted: {
if (find(editText) === -1)
model.append({text: editText})
}
}').arg(qsTr("Banana"))
.arg(qsTr("Apple"))
.arg(qsTr("Coconut"))
2023-05-23 17:37:25 +08:00
}
}