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 Updated to NodeBB v4.3 + New Features

Allow user to add item to QComboBox

Scheduled Pinned Locked Moved General and Desktop
qcomboboxeditable
4 Posts 2 Posters 3.9k 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.
  • J Offline
    J Offline
    Joel Bodenmann
    wrote on 7 Jun 2015, 14:28 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 7 Jun 2015, 14:53
    0
    • J Joel Bodenmann
      7 Jun 2015, 14:28

      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 7 Jun 2015, 14:53 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)

      J 1 Reply Last reply 8 Jun 2015, 07:14
      0
      • K koahnig
        7 Jun 2015, 14:53

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

        J Offline
        J Offline
        Joel Bodenmann
        wrote on 8 Jun 2015, 07:14 last edited by Joel Bodenmann 6 Aug 2015, 07:15
        #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 8 Jun 2015, 07:40
        0
        • J Joel Bodenmann
          8 Jun 2015, 07:14

          @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 8 Jun 2015, 07:40 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

          1/4

          7 Jun 2015, 14:28

          • Login

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