Compare an event.key to a letter for comparison purposes



  • I have a list and want to strike a letter on the keyboard and have first item in the list starting with that letter be the new list position. I have the event.key and the string in each of the list items from which I can determine the first letter. What I cannot work out is how to do a comparison (in c++ it would be a simple cast of the char -> aski code so comparing 2 numbers). In QML I am comparing a char and a number which obviously does not work.

    Code snippet, this code works fine for 'H' but I need it to get generic for all event.keys

    @
    var txt = ""
    var ch = ""
    for( var i = currentIndex + 1; i < QMLManager.getListLength(); i++ )
    {
    txt = QMLManager.getItemByIndex(i).displayText
    ch = txt.charAt(0)
    if(ch.toUpperCase() === "H")
    {
    currentIndex = i
    break
    }
    }
    @


Log in to reply
 

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