Posted on

Qt QComboBox to QStringList

Here is a function you can throw at the top of your .cpp file to convert any QComboBox into a QStringList.

static QStringList ComboBoxToStringList(
    QComboBox* comboBox)
{
    QStringList list;
    
    if(comboBox != nullptr)
    {
        int index = 0;
        while(index < comboBox->count())
        {
            list.append(comboBox->itemText(index));
            index++;
        }
    }
    
    return list;
}