PDA

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



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

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

ChrisW67
12th April 2012, 01: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, 12:26
Qt::Key key = Qt::Key_W;
qDebug() << QKeySequence(key).toString();
No longer necessary.