Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved How to programmatically set row in a QStringListModel?

    General and Desktop
    2
    4
    253
    Loading More Posts
    • 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.
    • mzimmers
      mzimmers last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 2
        • mzimmers
          mzimmers last edited by

          • sigh *

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

          Thanks, SGaist...

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • First post
              Last post