Search code examples
c++qtcountqcombobox

Does QComboBox::count() include separators in the count?


If I do:

QComboBox *cb = ...; 

cb->clear();
cb->addItem(...);
cb->insertSeparator(1);
cb->addItem(...);

Is cb->count() going to return 2 or 3?


Solution

  • QComboBox::AddItem is a shortcut to insert an item in the last position; the default insert method is QComboBox::InsertItem which is invoked by AddItem and increment the items count; QComboBox::InsertSeparator invokes InsertItem so, yes, a separator count as an item