Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set the current index in QCombo box
summit last edited by Christian Ehrlicher
this is the code i am using for QComboBox
QComboBox *comboboxAlignment = new QComboBox; comboboxAlignment->addItem("Left"); comboboxAlignment->addItem("Center"); comboboxAlignment->addItem("Right");
like we can set the index of combo box using a int value comboboxAlignment->setCurrentIndex(0)
can i do it by passing the string value for example if is pass "Right" than the item in the combo box having "Right" as text should become current item.
JonB last edited by JonB
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.