QML: Set Property of Nested ListElement

Viewed 888

I have a ListModel like the following:

ListModel {
  id: liveFeedModel

  ListElement {
    modelSrc: [
        ListElement { src: "../img/pano.jpg" },
        ListElement { src: "../img/pano1.jpg" },
        ListElement { src: "../img/pano2.jpg" },
        ListElement { src: "../img/pano3.jpg" }
    ]
    name: "Cookies"
    temp: "456 °C"
    time: "--:--"
  }

  ListElement {
    modelSrc: [
        ListElement { src: "../img/pano2.jpg" }
    ]
    name: "Sourdough Roll"
    temp: "123 °F"
    time: "--:--"
  }
}

And I would like to set the value of the nested ListElements within modelSrc.

I am looking for something similar to:

liveFeedModel.get(0).modelSrc.get(2).src

except with set, setProperty, or something along those lines, instead of get

Thanks in advance

1 Answers

use:

myListView.model.get(0).modelSrc.setProperty(0, "src", "../img/pano2.jpg");

simple as that!

Related