PDA

View Full Version : How convert Qt::Key to QString?



lenny
11th April 2012, 15:24
How convert Qt::Key to QString?

mvuori
11th April 2012, 16:17
1) Check that it is in the range of characters and 2) create a string with QString::number(code)

ChrisW67
12th April 2012, 02:06
How convert Qt::Key to QString?

Do you want to take:


Qt::Key key = Qt::Key_Semicolon;

and turn it into ";" or "Qt::Key_Semicolon"?

If you got the Qt::Key value in a QKeyEvent then QKeyEvent::text() may be useful.

lenny
12th April 2012, 13:26
Qt::Key key = Qt::Key_W;
qDebug() << QKeySequence(key).toString();
No longer necessary.