Important: Please read the Qt Code of Conduct -

Problems setting ComboBox currentIndex

  • QuickControls 2 using Qt 5.11....

    I've got a comboBox, and I'm trying to change the model and current index for it using javascript on a property change:

    onMyPropertyChanged: {
            if (MyProperty <100){
                 model= ["15"];
                  myComboBox.currentIndex = 0;
           else {
                myComboBox.currentIndex = 1;

    I'm seeing the correct choices in the menu after the property change happens, but the menu looks blank, as if index -1 has been chosen. If I print the currentText for the comboBox, it reports the correct choice is selected, but it's not showing.

    Is there some sort of refresh that needs to happen in order to see the correct index showing?

  • @igor_stravinsky hi,

    you don't need to refresh, i just tested this and it works a expected

    Window {
        visible: true
        width: 640
        height: 480
        property bool tgl:false
        onTglChanged: {
            combo.model = ["1111","2222","3333"]
        ComboBox {
            editable: true
            anchors.centerIn: parent
            onClicked: tgl = !tgl
            text:"combo index : " + combo.currentIndex

Log in to reply