From 9e45ab31364734fbd34ea1c3a611d70fedfa92e9 Mon Sep 17 00:00:00 2001 From: Stefan Dunca Date: Fri, 16 Aug 2019 14:55:25 +0200 Subject: [PATCH] Fix combobox usage --- src/AutoPilotPlugins/PX4/AirframeComponent.qml | 1 + src/QmlControls/QGCComboBox.qml | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.qml b/src/AutoPilotPlugins/PX4/AirframeComponent.qml index 1508026a1..d8affe7cd 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.qml +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.qml @@ -229,6 +229,7 @@ Your vehicle will also be restarted in order to complete the process.") anchors.left: parent.left anchors.right: parent.right model: modelData.airframes + textRole: "text" Component.onCompleted: { if (airframeCheckBox.checked) { diff --git a/src/QmlControls/QGCComboBox.qml b/src/QmlControls/QGCComboBox.qml index 8a02e7642..2b918c95a 100644 --- a/src/QmlControls/QGCComboBox.qml +++ b/src/QmlControls/QGCComboBox.qml @@ -37,7 +37,15 @@ ComboBox { width: control.width contentItem: Text { - text: textRole ? modelData[textRole] : modelData + text: { + if(modelData) { + return textRole ? modelData[textRole] : modelData + } + else { + console.warn("ComboBox: no model data") + return "" + } + } color: control.currentIndex === index ? qgcPal.buttonHighlightText : qgcPal.buttonText verticalAlignment: Text.AlignVCenter } -- 2.22.0