Using editable ComboBox
-
wrote on 18 Nov 2020, 10:47 last edited by
As the title says I am looking for an editable ComboBox in QML.
I have seen the examples and used already ComboBoxes in my applications. For static cases this is fine and easy to use.
I am struggling with implementing an editable, variable ComboBox. Part of the entries shall be fixed, but extendible through the user. Any addition shall be available for the next call or a new start of the application.
The editable property of ComboBox can be set. That is working, but when I choose a different entry and reopen the dialog again the added edited entry is gone.
Some guidance on this is appreciated.
-
As the title says I am looking for an editable ComboBox in QML.
I have seen the examples and used already ComboBoxes in my applications. For static cases this is fine and easy to use.
I am struggling with implementing an editable, variable ComboBox. Part of the entries shall be fixed, but extendible through the user. Any addition shall be available for the next call or a new start of the application.
The editable property of ComboBox can be set. That is working, but when I choose a different entry and reopen the dialog again the added edited entry is gone.
Some guidance on this is appreciated.
hi @koahnig
the important part is, where to you store/ assign the model to your combobox ?
you'll have to react to the
accepted
signal of the combobox and add the new entry to the model to preserve it for the next creation -
hi @koahnig
the important part is, where to you store/ assign the model to your combobox ?
you'll have to react to the
accepted
signal of the combobox and add the new entry to the model to preserve it for the next creationwrote on 19 Nov 2020, 13:35 last edited by@J-Hilk
Thanks for reply.
Finally I found this documentation entry https://doc.qt.io/qt-5/qml-qtquick-controls2-combobox.html#editable-combobox
That is providing some clue which route to go. It points also to ListModel as the way to go. At least with ListModel I could get some reasonable solution while other as a StringList as found in most examples are a dead end.
QML respectively is a bit confusing IMHO. -
wrote on 20 Nov 2020, 17:22 last edited by
Thought initially that the issue could be completely solved in qml, but Settings seem to miss some features as present in QSettings. Therefore decided to move forward with solution based on C++ with QML.
https://forum.qt.io/topic/120954/combobox-together-with-qstringlistmodel
1/4