1

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

utkuyceng
  • 43
  • 6
  • 2
    Have a look at this post https://stackoverflow.com/questions/7659442/listelement-fields-as-properties – iam_peter Jan 03 '23 at 11:05
  • 2
    Can you explain why the links you posted do not solve your problem? They seem to directly address your question. – JarMan Jan 03 '23 at 14:53
  • 1
    iam_peter and JarMan are correct. That should have been more than enough to explain what is wrong. – Stephen Quan Jan 04 '23 at 00:46
  • The reason was i did not understand "onFirstValueChanged" or "onSecondValueChanged" is created automatically. I thought it was a standart for qml but now i see. I created a 3 element ListElement and its now working. My further question is, how can i read the whole data of an appended element. My ListElement id is "programSteps" and now it has 3 elements appended in. How can i reach the programSteps[0] or programSteps[0].name? I appended like append ({ name: "heat", values: programSteps.temperature }) – utkuyceng Jan 04 '23 at 08:53
  • 1
    programSteps.get(0).name ? You can try it online here: https://stephenquan.github.io/qmlonline/?zcode=AAAB1nictZDLDsIgEEX3fMWkq3ZDjMu6bHRhfEZ/gOhYiTwaGIxN03+3qNGqW70LyAXm3BmkrqwjWNM6yN2JyTfLC2vIWeU/z2eitoE8W4kSoWHQaSY9ze0e1cNHyX0OlbOlE3pDWPnnRXw8VqjREDRghMYckiMKSkZwFipEOxwk0N4q7mthVdDmntzLmHRw7PmoLV4il7oth+lmueCenDSlPNRpvx9eIqWDLHskvLJ+BOZxsv/Rbz/1jW9ZewXnhYj7 – Stephen Quan Jan 04 '23 at 21:37
  • I used some other method but this one is wild good! Thank you @StephenQuan – utkuyceng Jan 05 '23 at 15:16

0 Answers0