Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-51698

ComboBox can't set empty string ("") as current text from code

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 5.5.1
    • Quick: Controls 1
    • None
    • Win 8.1 64bit, Qt Creator 3.6.1, Qt 5.5.1 MinGW 32 bit

    Description

      To test this issue I have create "Qt Quick Controls Application" from File->Create File or Project (Ctrl + N), set "Minimal required Qt version" to 5.5 (but I actually don't think that this is important) and added few lines of code to standart template:

      Difference with template
      diff --git a/Default/Main.qml b/QMLTest/Main.qml
      index 1d3f6bd..38d0a5a 100644
      --- a/Default/Main.qml
      +++ b/QMLTest/Main.qml
      @@ -24,8 +24,8 @@ ApplicationWindow {
       
           MainForm {
               anchors.fill: parent
      -        button1.onClicked: messageDialog.show(qsTr("Button 1 pressed"))
      -        button2.onClicked: messageDialog.show(qsTr("Button 2 pressed"))
      +        button1.onClicked: {comboBox1.currentIndex = 0}
      +        button2.onClicked: {comboBox1.currentIndex = 2}
           }
       
           MessageDialog {
      diff --git a/Default/MainForm.ui.qml b/QMLTest/MainForm.ui.qml
      index b11a1c2..a092278 100644
      --- a/Default/MainForm.ui.qml
      +++ b/QMLTest/MainForm.ui.qml
      @@ -8,6 +8,7 @@ Item {
       
           property alias button1: button1
           property alias button2: button2
      +    property alias comboBox1: comboBox1
       
           RowLayout {
               anchors.centerIn: parent
      @@ -22,5 +23,12 @@ Item {
                   text: qsTr("Press Me 2")
               }
           }
      +
      +    ComboBox {
      +        id: comboBox1
      +        x: 258
      +        y: 158
      +        model:["","test1","test2"]
      +    }
       }
      

      Result: when I pressed to button2 everything is good (i.e. combobox text becomes "test2"), but when I pressed to button1, nothing happens. I have tried to put "" to anothet position in model, but I have got the same result

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            aknew85 Alexander Kazansky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes