ComboBox text reset on model update
-
Hello! As far as I understand, in ComboBox every time model gets updated from C++, the text in editable Text Edit gets erased. Is there a way to update model without resetting text? And also, is there a way to have a dropdown list opened and being able to write in text edit?
-
hi @Imynnand welcome
Is there a way to update model without resetting text?
possibly this:
ComboBox{ id:myCombobox anchors{ left: parent.left right: parent.right top: parent.top } height: 50 editable: true Binding{ target: myCombobox property: "model" value: root.count when: !myCombobox.activeFocus } } property int count: 1 Timer{ id:changeModel running: true interval: 1000 repeat: true onTriggered: count++ }
And also, is there a way to have a dropdown list opened and being able to write in text edit
you probably will have to overwrite the popup component of the combox to modify that behaviour
-
@J-Hilk Thank you for your reply! I can see that this binding adds something to model. But what if I type something in text edit, and in my C++ code the model gets reset. For example, I have TextField in ComboBox
TextField { text: root.editText onTextChanged: { updateModel() }
void CustomModel::updateModel() { beginResetModel(); endResetModel(); }
But whenever it happens, text in text edit gets erased. So for example. I write one letter in text edit, model gets updated, then I type another letter, and the text gets erased. The most interesting thing is that text that I typed gets erased every second attempt to write something. And if there was some text before it remains unchanged, only my input is affected. Any ideas why it happens? Thank you