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.
    Thanks



  • @Naveen_D said in list of strings:

    "good","better,"best"

        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]
                    break;
                }
                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
 

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