QCombobox with model: Can't select from list
I am seeing some weird behavior from my QCombobox, and I'm hoping someone can help me understand what is going on.
I've got a dialog that has a QCombobox in it. I am using a QAbstractListModel and QSortFilterProxyModel to populate the QCombobox's list view. This all seems to be working.
Initially the list is empty. If type a new entry into the QCombobox and click on my 'OK' button, the CurrentIndex is set to -1 (which I expect), and I add the new entry to my data source. This all seems to be working.
If I open my dialog again (now there is one item in the list), I can click on the drop-down arrow on the QCombobox, and I will see the new entry in the list, but I cannot select it. Even if I don't view the list, if I type a new entry into the QCombobox and click 'OK', I find the CurrentIndex is set to 0.
What am I doing wrong?
Could you verify that the model behaves as expected outside of the contect of a QComboBox? Preferably by using the ModelTest tool, but if needed by just putting it in a list view?
I added a list view, and it looks correct. I also noticed that if I don't try to select from the combobox's list, my currentIndex stays at -1 like it should.
If I try to select from the list, the currentIndex is updated correctly, but the selected item is not displayed by the combobox.
In the virtual function data() , when the role == Item::EditRole | Item::DisplayRole, valid data should be returned.