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. Editable Combobox not saving edited text

Editable Combobox not saving edited text

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 3 Posters 2.0k Views 2 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.
  • M Offline
    M Offline
    MTOLANI
    wrote on last edited by
    #1

    I have a editable combobox which is showing suggestions on entering text.
    But if I am editing the current text, its not being saved.
    After I make changes, it goes to onAccepted method in Combobox, finds the currect index but does not save it.
    When I click on some other page and come back the combobox is back to the previous selection.
    Please help.

    1 Reply Last reply
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by jpnurmi
      #2

      ComboBox leaves it up to you to decide what happens when the input is accepted. See the example in the docs:

      ComboBox {
          editable: true
          model: ListModel {
              id: model
              ListElement { text: "Banana" }
              ListElement { text: "Apple" }
              ListElement { text: "Coconut" }
          }
          onAccepted: {
              if (find(editText) === -1)
                  model.append({text: editText})
          }
      }
      
      1 Reply Last reply
      2
      • M Offline
        M Offline
        MTOLANI
        wrote on last edited by
        #3

        After I change any value, my code goes to onAccepted method in ComboBox and does not hit the method I have written here.
        Is there something which I am missing out?

        jpnurmiJ 1 Reply Last reply
        0
        • M MTOLANI

          After I change any value, my code goes to onAccepted method in ComboBox and does not hit the method I have written here.
          Is there something which I am missing out?

          jpnurmiJ Offline
          jpnurmiJ Offline
          jpnurmi
          wrote on last edited by
          #4

          my code ... does not hit the method I have written here.

          I don't know what method you are talking about and how is it connected to this. I'm afraid we need to see some code to be able to help further.

          JonBJ 1 Reply Last reply
          0
          • jpnurmiJ jpnurmi

            my code ... does not hit the method I have written here.

            I don't know what method you are talking about and how is it connected to this. I'm afraid we need to see some code to be able to help further.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @jpnurmi
            I assume OP means/claims the onAccepted is not hit, with the above example as copied from the specified https://doc.qt.io/qt-5.10/qml-qtquick-controls2-combobox.html#editable-combobox link.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MTOLANI
              wrote on last edited by
              #6

              Hi thanks for your help.
              I had earlier written the method as :

              category.onAccepted : {
              console.log("Print onAccepted");
              }
              

              The below code solved the issue.

              Connections{
                      target: category
                      onAccepted : {
                         console.log("Print onAccepted");
                      }
                  }
              
              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