Important: Please read the Qt Code of Conduct -

How to set the current index in QCombo box

  • this is the code i am using for QComboBox

    QComboBox *comboboxAlignment = new QComboBox;

    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.

  • @summit
    setCurrentText(const QString &text)

    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.

Log in to reply