QComboBox *comboBox = new QComboBox(parent); comboBox->setToolTip("Select an item from the list.");
QStringList items = {"Option 1", "Option 2", "Option 3"}; QComboBox *comboBox = new QComboBox(parent); comboBox->addItems(items); comboBox->setToolTip(QString("Select one of the %1 options.").arg(items.size()));In this example, a QStringList is created with three options, which are then added to the QComboBox. A tool tip is set with the message "Select one of the 3 options." The number of options is determined dynamically using the size method of the QStringList. Package library: Qt