How to set CurrentText of QComboBox?
Unsolved
General and Desktop
-
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.
The
ui->comboBox->setCurrentText(QString::number(i));
or:
ui->comboBox->setWindowTitle(QString::number(i));
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.
-
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.