If I do:
QComboBox *cb = ...;
cb->clear();
cb->addItem(...);
cb->insertSeparator(1);
cb->addItem(...);
Is cb->count()
going to return 2
or 3
?
The separators count. The count()
will be equal to 3.
#include <QtWidgets>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QComboBox cb;
cb.addItem("Foo");
cb.insertSeparator(1);
cb.addItem("Bar");
Q_ASSERT(cb.count() == 3);
return 0;
}
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