NComboBox not default options

This commit is contained in:
quadbyte 2025-08-11 14:54:54 -04:00
parent 3e46eed9a1
commit 8cc3c47f09
2 changed files with 10 additions and 7 deletions

View file

@ -133,10 +133,12 @@ NLoader {
font.weight: Style.fontWeightBold font.weight: Style.fontWeightBold
} }
NComboBox {// label: "Label" NComboBox {
// description: "Description" optionsKeys: ["cat", "dog", "bird", "monkey", "fish", "turtle", "elephant", "tiger"]
optionsLabels: ["Cat", "Dog", "Bird", "Monkey", "Fish", "Turtle", "Elephant", "Tiger"]
currentKey: "cat"
onSelected: function (value) { onSelected: function (value) {
console.log("NComboBox: " + value) console.log("NComboBox: selected " + value)
} }
} }

View file

@ -8,9 +8,10 @@ ComboBox {
id: root id: root
readonly property real scaling: Scaling.scale(screen) readonly property real scaling: Scaling.scale(screen)
property list<string> optionsKeys: ['cat', 'dog', 'bird', 'monkey', 'fish', 'turtle', 'elephant', 'tiger']
property list<string> optionsLabels: ['Cat ', 'Dog', 'Bird', 'Monkey', 'Fish', 'Turtle', 'Elephant', 'Tiger'] property list<string> optionsKeys: []
property string currentKey: "cat" property list<string> optionsLabels: []
property string currentKey: ''
property var onSelected: function (string) {} property var onSelected: function (string) {}
Layout.fillWidth: true Layout.fillWidth: true
@ -19,7 +20,7 @@ ComboBox {
model: optionsKeys model: optionsKeys
currentIndex: model.indexOf(currentKey) currentIndex: model.indexOf(currentKey)
onActivated: { onActivated: {
root.onSelected(model[currentIndex]) root.onSelected(model[currentIndex])
} }
// Rounded background // Rounded background