Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Compare an event.key to a letter for comparison purposes
Forum Updated to NodeBB v4.3 + New Features

Compare an event.key to a letter for comparison purposes

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 690 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dolphin
    wrote on last edited by
    #1

    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
    }
    }
    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved