#include// Create the QComboBox object QComboBox* comboBox = new QComboBox(parent); // Add items to the combo box comboBox->addItem("Option 1"); comboBox->addItem("Option 2"); comboBox->addItem("Option 3"); // Enable line edit so that user can add custom text comboBox->setEditable(true);
// Create the QComboBox object QComboBox* comboBox = new QComboBox(parent); // Add items to the combo box comboBox->addItem("Option 1"); comboBox->addItem("Option 2"); comboBox->addItem("Option 3"); // Enable line edit and connect its textChanged signal to a custom slot comboBox->setEditable(true); connect(comboBox->lineEdit(), SIGNAL(textChanged(const QString &)), this, SLOT(myCustomSlot(const QString &)));Both examples use the Qt C++ library.