Combobox



  • Hello

    In combobox, say it contains , model: [ "A", "B", "C", "D" ] . What would be the currentIndex of A, if I give 0 it isn't taking A it points to B.



  • Double check your code. This points to "A" no matter if I use Qt Quick Controls 1 or 2.

    import QtQuick 2.6
    import QtQuick.Controls 2.0 // or 1.0
    
    ApplicationWindow {
        visible: true
    
        ComboBox {
            currentIndex: 0
            model: [ "A", "B", "C", "D" ]
        }
    }


  • @jpnurmi said in Combobox:

    currentIndex: 0

    Thank you for ur reply. My problem is if I select A from the combbox it should open another qml, for that am using currentIndex. If I give obj.currentIndex=0 it should refer A and perform corresponding action, instead it takes B as 0th index and performs B's action.



  • Then you might want to provide a simple test case to reproduce the problem. It will help people to help you.



  • You could also possibly use currentText.

    Combining it with the currentTextChanged signal might be useful. Then it would look something like this

    import QtQuick 2.6
    import QtQuick.Controls 2.0 // or 1.0
    
    ApplicationWindow {
        visible: true
    
        ComboBox {
            currentIndex: 0
            model: [ "A", "B", "C", "D" ]
            onCurrentTextChanged: openQML(currentText)
        }
    }
    

    Where openQML(currentText) would be however you are choosing to open your QML file


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.