Allow user to add item to QComboBox
I would like to give the user the ability to use an editable QComboBox to add a new item to the list. Is that possible? So far I was able to create a custom model class and assign it to the editable QComboBox but that doesn't solve the issue of adding a new item to the list.
I could create a new button next to the combobox allowing the user to add a new item to the list but I think that's the less elegant solution.
@koahnig I can successfully add items to the QComboBox now. My problem is that I need to use a custom model and assign it to the QComboBox because the QComboBox only creates a new string.
What I need to do is adding a new item in my own model when the user creates a new one. How do I do that? Will the QComboBox call insertRow() in my list model?
Not sure what you mean with own model.
When you want that the user is able to add to the combobox only text which follows your specific rules, you may use a QValidator.
Just saw the setModel of QCombobox most likely you need to use one of QCombobox signals (e.g. editTextChanged) and add it to the model through your own slot method. However, never used that yet.