Browse Source

FactComboBox: keep index onModelChanged

QGC4.4
Beat Küng 3 years ago
parent
commit
821461879e
  1. 11
      src/FactSystem/FactControls/FactComboBox.qml

11
src/FactSystem/FactControls/FactComboBox.qml

@ -14,6 +14,17 @@ QGCComboBox { @@ -14,6 +14,17 @@ QGCComboBox {
currentIndex: fact ? (indexModel ? fact.value : fact.enumIndex) : 0
onModelChanged: {
// When the model changes, the index gets reset to 0, so make sure to
// restore it correctly.
// Since enumIndex could trigger a model change, we use callLater() to
// avoid an event binding loop (the 2. call will for certain not trigger
// another model change)
Qt.callLater(function() {
currentIndex = fact ? (indexModel ? fact.value : fact.enumIndex) : 0
})
}
onActivated: {
if (indexModel) {
fact.value = index

Loading…
Cancel
Save