How to use property variables in ListElement

199 Views Asked by At

I am trying to build an ListModel with Listelements by using pre-defined variables in qml. The error i am getting is "QQmlComponent: Component is not ready", "cannot use script for property value"

On my code, i removed the css or qss edits on purpose, to show code clear

I want to use this property

property string cellTemperature: "0"

in this ListModel

ListModel {
id: mainValuesList
ListElement { name: "CELL"; listValue: cellTemperature ; sdValue: "_ _SD"}
}

and then create a GridView

GridView {
id: mainValuesGrid
anchors.fill: parent
model: mainValuesList
delegate: Rectangle {

    width: 120
    height: 80
    color: "transparent"

    Text{
        color: "#4A4A4A"
        text: name
    }

    Text{
        color: "#4A4A4A"
        text: listValue
    }

    Text{
        color: "#4A4A4A"
        text: sdValue
    }
  }
}

I tried to use QT_TR_NOOP(cellTemperature) qsTr(cellTemperature)

But they both did not work. Here are the threads i focused but could not find a solution

Why can ListElement add arbitrary properties?

ListElement fields as properties?

Get properties of QML ListElement

0

There are 0 best solutions below