[solved] Add object to ListModel statically



  • 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?



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



  • 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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.