Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Allow user to add item to QComboBox
Forum Update on Monday, May 27th 2025

Allow user to add item to QComboBox

Scheduled Pinned Locked Moved General and Desktop
qcomboboxeditable
4 Posts 2 Posters 3.8k Views
  • 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.
  • Joel BodenmannJ Offline
    Joel BodenmannJ Offline
    Joel Bodenmann
    wrote on last edited by
    #1

    I would like to give the user the ability to use an editable QComboBox to add a new item to the list. Is that possible? So far I was able to create a custom model class and assign it to the editable QComboBox but that doesn't solve the issue of adding a new item to the list.

    I could create a new button next to the combobox allowing the user to add a new item to the list but I think that's the less elegant solution.

    And ideas?

    Industrial process automation software: https://simulton.com
    Embedded Graphics & GUI library: https://ugfx.io

    K 1 Reply Last reply
    0
    • Joel BodenmannJ Joel Bodenmann

      I would like to give the user the ability to use an editable QComboBox to add a new item to the list. Is that possible? So far I was able to create a custom model class and assign it to the editable QComboBox but that doesn't solve the issue of adding a new item to the list.

      I could create a new button next to the combobox allowing the user to add a new item to the list but I think that's the less elegant solution.

      And ideas?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Joel-Bodenmann
      Yes, that is possible by using the editable property.

      Vote the answer(s) that helped you to solve your issue(s)

      Joel BodenmannJ 1 Reply Last reply
      0
      • K koahnig

        @Joel-Bodenmann
        Yes, that is possible by using the editable property.

        Joel BodenmannJ Offline
        Joel BodenmannJ Offline
        Joel Bodenmann
        wrote on last edited by Joel Bodenmann
        #3

        @koahnig I can successfully add items to the QComboBox now. My problem is that I need to use a custom model and assign it to the QComboBox because the QComboBox only creates a new string.
        What I need to do is adding a new item in my own model when the user creates a new one. How do I do that? Will the QComboBox call insertRow() in my list model?

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

        K 1 Reply Last reply
        0
        • Joel BodenmannJ Joel Bodenmann

          @koahnig I can successfully add items to the QComboBox now. My problem is that I need to use a custom model and assign it to the QComboBox because the QComboBox only creates a new string.
          What I need to do is adding a new item in my own model when the user creates a new one. How do I do that? Will the QComboBox call insertRow() in my list model?

          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @Joel-Bodenmann

          Not sure what you mean with own model.
          When you want that the user is able to add to the combobox only text which follows your specific rules, you may use a QValidator.
          Just saw the setModel of QCombobox most likely you need to use one of QCombobox signals (e.g. editTextChanged) and add it to the model through your own slot method. However, never used that yet.

          Vote the answer(s) that helped you to solve your issue(s)

          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