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 to programmatically set row in a QStringListModel?
QtWS25 Last Chance

How to programmatically set row in a QStringListModel?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 499 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi -

    I have a QStringListModel that is used by a QComboBox to represent the current state of an object. This state can be changed by the user (using the QComboBox) but it can also change remotely. When it does, my program is informed with a message. I can get the value of the new state, but I don't know what to do with it. It seems like I'd want a setRow() command for the model, but I don't see anything like that. Can someone shed some light on this for me?

    Thanks...

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

      Hi,

      That's something you do at the combo box level. The model itself doesn't know anything about selection. Use QComboBox::setCurrentIndex with the value returned by QComboBox::findText.

      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
      2
      • mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3
        • sigh *

        It's soooo easy when you know how, isn't it?

        Thanks, SGaist...

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

          You're welcome !

          It's the same as for everything: practice and practice again and it will come :)

          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

          • Login

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