Get the “name” of a key from QKeyEvent in Qt
问题 Is there an easy way of getting the name of a key (so something like "uparrow" from a key event instead of just getting the key code "16777235")? Do I have to make a list of key names myself? 回答1: Using human-readable names in your code You can use the Qt::Key enum, or get the key as a string with QKeyEvent::text(). From QKeyEvent documentation: int QKeyEvent::key () const Returns the code of the key that was pressed or released. See Qt::Key for the list of keyboard codes. These codes are