Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Editable Combobox not saving edited text
Qt 6.12 LTS is out! See what's new in the release blog

Editable Combobox not saving edited text

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 3 Posters 3.7k 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
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #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?

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

          ? Offline
          ? Offline
          A Former User
          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
          • ? A Former User

            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
              • Unsolved