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. QKeyEvent: check if the character is a letter or a digit

QKeyEvent: check if the character is a letter or a digit

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.4k Views
  • 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.
  • LorenDBL Offline
    LorenDBL Offline
    LorenDB
    wrote on last edited by
    #1

    I have a custom keyPressEvent handler in a QWidget. I'd like to be able to decide if the key that has been pressed is a letter/number or if it is something else (e.g. alt, control, ...). Formerly, I've been simply comparing the keycode to the literal values of Qt::Key_A through Qt::Key_Z, and Qt::Key_0 through Qt::Key_9. However, that doesn't work for special Unicode characters (such as things like "ĉ"). Is there any way to simply figure out whether the value of the key is a letter/number or not?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      Use QKeyEvent::text() to get a QString of the input.

      1 Reply Last reply
      2

      • Login

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