From 8cc3c47f097cc4b5f244a011ef71198f43eb3196 Mon Sep 17 00:00:00 2001 From: quadbyte Date: Mon, 11 Aug 2025 14:54:54 -0400 Subject: [PATCH] NComboBox not default options --- Modules/DemoPanel/DemoPanel.qml | 8 +++++--- Widgets/NComboBox.qml | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Modules/DemoPanel/DemoPanel.qml b/Modules/DemoPanel/DemoPanel.qml index 331a989..f2ca9fd 100644 --- a/Modules/DemoPanel/DemoPanel.qml +++ b/Modules/DemoPanel/DemoPanel.qml @@ -133,10 +133,12 @@ NLoader { font.weight: Style.fontWeightBold } - NComboBox {// label: "Label" - // description: "Description" + NComboBox { + optionsKeys: ["cat", "dog", "bird", "monkey", "fish", "turtle", "elephant", "tiger"] + optionsLabels: ["Cat", "Dog", "Bird", "Monkey", "Fish", "Turtle", "Elephant", "Tiger"] + currentKey: "cat" onSelected: function (value) { - console.log("NComboBox: " + value) + console.log("NComboBox: selected " + value) } } diff --git a/Widgets/NComboBox.qml b/Widgets/NComboBox.qml index cf24759..a936170 100644 --- a/Widgets/NComboBox.qml +++ b/Widgets/NComboBox.qml @@ -8,9 +8,10 @@ ComboBox { id: root readonly property real scaling: Scaling.scale(screen) - property list optionsKeys: ['cat', 'dog', 'bird', 'monkey', 'fish', 'turtle', 'elephant', 'tiger'] - property list optionsLabels: ['Cat ', 'Dog', 'Bird', 'Monkey', 'Fish', 'Turtle', 'Elephant', 'Tiger'] - property string currentKey: "cat" + + property list optionsKeys: [] + property list optionsLabels: [] + property string currentKey: '' property var onSelected: function (string) {} Layout.fillWidth: true @@ -19,7 +20,7 @@ ComboBox { model: optionsKeys currentIndex: model.indexOf(currentKey) onActivated: { - root.onSelected(model[currentIndex]) + root.onSelected(model[currentIndex]) } // Rounded background