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] Add object to ListModel statically
Forum Updated to NodeBB v4.3 + New Features

[solved] Add object to ListModel statically

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 999 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.
  • A Offline
    A Offline
    AnatoliyL
    wrote on last edited by
    #1

    I need to create ListModel, that contains object (string and bool inside) statically. If i add to empty ListModel element by using append - all works well

    @
    property ListModel qwe: ListModel {}
    var image { value: "picture.png", imageType: 1 }

    qwe.append({
    text: "TextToAdd",
    image: imageToADD,
    position: 1
    })
    // This works correct
    @
    But i need to create ListModel statically and it doesnt work^
    @
    ListModel {
    ListElement {
    text: "TextToAdd"
    image: { value: "Qwer.png", imageType: 1 } // <-- This doesnt work
    position: 1
    }
    }
    @
    How it should look like?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kysymys
      wrote on last edited by
      #2

      I think this should work:
      @ListModel {
      ListElement {
      text: "TextToAdd"
      image: { "value": "Qwer.png", "imageType": 1 }
      position: 1
      }
      }
      @

      \o/ \o/ Kudos ...

      Paholaisen Kysymys

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AnatoliyL
        wrote on last edited by
        #3

        I see the difference between ur example and second example in my post only in quotes. I will try it, but i'm 90% sure that it wont work

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kysymys
          wrote on last edited by
          #4

          If this solved your question, please change the question title so that it starts with [solved] and add a solved tag.

          \o/ \o/ Kudos ...

          Paholaisen Kysymys

          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