Solved Editable Combobox not saving edited text
-
I have a editable combobox which is showing suggestions on entering text.
But if I am editing the current text, its not being saved.
After I make changes, it goes to onAccepted method in Combobox, finds the currect index but does not save it.
When I click on some other page and come back the combobox is back to the previous selection.
Please help. -
ComboBox leaves it up to you to decide what happens when the input is accepted. See the example in the docs:
ComboBox { editable: true model: ListModel { id: model ListElement { text: "Banana" } ListElement { text: "Apple" } ListElement { text: "Coconut" } } onAccepted: { if (find(editText) === -1) model.append({text: editText}) } }
-
After I change any value, my code goes to onAccepted method in ComboBox and does not hit the method I have written here.
Is there something which I am missing out? -
my code ... does not hit the method I have written here.
I don't know what method you are talking about and how is it connected to this. I'm afraid we need to see some code to be able to help further.
-
@jpnurmi
I assume OP means/claims theonAccepted
is not hit, with the above example as copied from the specified https://doc.qt.io/qt-5.10/qml-qtquick-controls2-combobox.html#editable-combobox link. -
Hi thanks for your help.
I had earlier written the method as :category.onAccepted : { console.log("Print onAccepted"); }
The below code solved the issue.
Connections{ target: category onAccepted : { console.log("Print onAccepted"); } }