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. [SOLVED]Adding subitems to ListModel
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Adding subitems to ListModel

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.5k 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.
  • C Offline
    C Offline
    cmer4
    wrote on last edited by
    #1

    Hello folks, searched this forum and googled a bit but found no reply yet to the following important question:

    ListModel can have elements added via simple ListModel.append command.

    Is there a way to add data to the element highlighted below? (e.g. to add a subitem to the ListModel via append command?)

    @ListElement {
    itemTitle: "Item title 1"
    attributes: [
    ListElement { subItemTitle: "Subitem title 1/1" } // Is there a way to add these using append?
    ListElement { subItemTitle: "Subitem title 2/1" }
    ]
    }@

    UPDATE: well ofc course this was pretty lame...:

    Solution:
    @testModel.append({"itemTitle":"Item title 2", "attributes":[{"subItemTitle":"Subitem title 1/2"}]})@

    But truth is - for people like me this is supposed to be in the documentation...

    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