Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED]QtQuick Combobox reset list index not working



  • Hi,

    I'm trying to sort simple problem to clear qtquick combobox from selected item in documention i read it should be done via set currentindex to -1 but its only clear selection in the list but text in combo still rest the same is there any way to clear it?

    Example below.

    Thanks for any advice.

    @import QtQuick 2.1
    import QtQuick.Controls 1.1
    import QtQuick.Window 2.0

    ApplicationWindow {
    title: qsTr("Hello World")
    width: 640
    height: 480

      Column{
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter
    
        ComboBox{
            id: cbo_Test
            model: ["AAA","BBB","CCC"]
    
        }
    
        Button {
            text: qsTr("Clear Selection")
            onClicked: {
                cbo_Test.currentIndex = -1
            }
        }
    
    }
    

    }
    @


  • Moderators

    Hi,

    Do you mean that you want to show the first item after clicking the button ?



  • Hi,

    after click on the button there should be nothing selected in the combo. it's set index to -1 but combo text is still showing item from first positon index 0


  • Moderators

    Your code works fine on my system.
    But I'm using Qt 5.2.1.
    Which Qt version are you using ?


  • Moderators

    Hi,

    It seems to be bug in Qt 5.2.0. It is solved in Qt 5.2.1
    See "this":https://bugreports.qt-project.org/browse/QTBUG-35794



  • Hi p3c0,

    yes i was using version Qt 5.2.0 now upgraded to Qt 5.2.1 and it works fine.

    Thank you for your help.


Log in to reply