Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set CurrentText of QComboBox?
Engelard last edited by Engelard
I want to set the text of this widget when no item selected yet. At the beginning my comboBox is empty, then in runtime program adds elements to this box, and i want instantly display in comboBox some string("Elemens inside"+QString::number(i)). But i can't find proper function.
is not working, i don't know why...
P.S. i dont need change text of first item, i need only set initial text of the header of that box.
JonB last edited by JonB
You want to set the text in an editable
QLineEditwidget to some string, right? In what way does
ui->comboBox->setCurrentText(QString::number(i));not work? Please be precise.
is your Combobox editable? if not, setCurrentText will have no effect
The setter setCurrentText() simply calls setEditText() if the combo box is editable. Otherwise, if there is a matching text in the list, currentIndex is set to the corresponding index.