Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. updating a list model object based on another model?

updating a list model object based on another model?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 366 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    My app has a couple list models, one for equipment, and the other for what we refer to as "spaces." Each space has a list of equipment UUIDs (not an actual Equipment object).

    When I display my Equipment objects (in a GridView), I need to show whether the equipment is included in any of the Space lists. Currently, I'm using an invokable function in my Space model. The problem with this approach is that my display doesn't automatically change when an Equipment is added to a Space (which I understand).

    I'm trying to avoid adding an "assigned" property to my Equipment class, as this information is available elsewhere (in the Space objects), and I'd prefer not to duplicate information. But I can't figure out another way to do this.

    Is it possible to create a property for my Space model (not the Space class itself) that would accept an equipment UUID, and return whether this is assigned to any Space in the model?

    Any other suggestions are most welcome. Thanks...

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      According my understanding based on your problem statement

      1. Some methods must have in SpaceModel & return ifExist().. This object emit signal exist(..) or newAdded(..) signal.
      2. Space model should be connected with Slots in Eqp. Eqp can emit either dataChanged(...) or rowInserted(..) signal.
      3. GridView will update automatically.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      1
      • mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @dheerendra yes, you are correct. I needed to make one model aware of the other, in order to connect signals and slots. The rest was straightforward. Thanks.

        1 Reply Last reply
        0
        • mzimmersM mzimmers has marked this topic as solved on

        • Login

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