Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to remove current model from ComboBox?
Engelard last edited by Engelard
Hi. In some moment my app is needed to "clear" certain ComboBox from model i set previously. I can't rly find how to do this.
In google some said use nullptr, it was first thought that i got myself, but every object(i assume) must have valid model.
Which outputs in runtime this:
QComboBox::setModel: cannot set a 0 model
Second thing i found, is to set to empty model, which seems more logical.
But unfortunately there is no such property in such class(at least i don't have it).
yes simply hold an empty model (like new QStringListModel). The few bytes of "wasted" memory is negligible.
If you have multiple views/comboboxes you can use the same dummy model for all of them.