QComboBox* comboBox = new QComboBox(); // ... add items to the combo box ... QString currentText = comboBox->currentText(); // currentText now contains the currently selected item in the combo box
QComboBox* comboBox = new QComboBox(); // ... add items to the combo box ... connect(comboBox, &QComboBox::currentTextChanged, [](const QString& text) { // text now contains the currently selected item in the combo box });Both of these examples use the QComboBox class from the Qt library, which is included in the Qt package.