I need to get an QStringList
or an array containing all QString
s in a QComboBox
.
I can't find a QComboBox
method that does this, in fact I can't even find a QAbstractItemModel
method that does this.
Is this really my only option:
std::vector< QString > list( myQComboBox.count() );
for( auto i = 0; i < list.size(); i++ )
{
list[i] = myQComboBox.itemText( i );
}
Your answer looks fine, but you could also use a QStringList instead of a vector.
QStringList itemsInComboBox;
for (int index = 0; index < ui->combo_box->count(); index++)
itemsInComboBox << ui->combo_box->itemText(index);