Important: Please read the Qt Code of Conduct -

list of strings

  • Hi all
    how to create a list of strings in Qml ? like for example,
    list somename= {"good","better,"best"} and i want to compare it with other string, like if the given string is present in the list then display that string.

  • @Naveen_D said in list of strings:


        property var array: ["good","better","best"]
        Text {
            id: name
            anchors.centerIn: parent
            text: ""
            color: "black"
        Component.onCompleted: {
            var i = 0;
            console.log("Length +++++++ " + array.length)
            while(array.length > i)
                if(array[i] === "best")
                    console.log("Found +++++++ " + array[i])
                    name.text = array[i]

    Hope, you are looking for something like this.

    My suggestion is to keep more of business logic in C++ module and then expose them to QML UI.

Log in to reply