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. How update QStringListModel and combo box after initialization
Qt 6.11 is out! See what's new in the release blog

How update QStringListModel and combo box after initialization

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.7k Views 1 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.
  • mat007M Offline
    mat007M Offline
    mat007
    wrote on last edited by
    #1

    Hi,
    I use QStringListMode and QComboBox. I initialize model in constructor of main window and I fill list in other function. I dont how update combo box after I set model for comboBox.

    I try use update funcion but i tried use update function but it didnt work.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What do you mean by update the combo box ? Add new values to the QStringListModel ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • mat007M Offline
        mat007M Offline
        mat007
        wrote on last edited by
        #3

        Hi i add new value to list after i set model for combo box but combo box is empty.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You need to update the model also

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            moravas
            wrote on last edited by
            #5

            Hi,

            I had same problem as your.

            • you can get the pointer of the model by calling model() method on the combobox
            • at this point, you have two opportunities:
              ** if you have the displayable datas from another, you can reset the stringlist on the model
              ** simply insert a new row by calling the insertRow

            Regards,
            Norbert

            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