Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED]QtQuick Combobox reset list index not working
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]QtQuick Combobox reset list index not working

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    b3tchi
    wrote on last edited by
    #1

    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
            }
        }
    
    }
    

    }
    @

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

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

      157

      1 Reply Last reply
      0
      • B Offline
        B Offline
        b3tchi
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

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

          157

          1 Reply Last reply
          0
          • p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

            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

            157

            1 Reply Last reply
            0
            • B Offline
              B Offline
              b3tchi
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved