I'm new to Qt and advanced Programming. In my project, I have a QKeySequence
shortcut CTRL + PLUS & CTRL + MINUS keys. They work fine in numerical PLUS & MINUS Keys but, they don't trigger required action if used in OEM PLUS & MINUS Keys for German and Italian keyboard layout. I tested them in a simple program with KeyPressEvent()
to print debug message, still it did not trigger the action. I used nativeVirtualKey()
and I was able to print the debug message. I used Qt 5.5.0 and 5.5.1 and test them using windows onscreen keyboard. Is there anyway to use CTRL + + shortcut in QKeySequence
for keyboards without numerical keys.
Another observation in same issue is faced in Qt Creator. The CTRL + PLUS shortcut to increase font size does not work in German keyboard and for the Danish keyboard it's the CTRL + MINUS that does not work.
QKeySequnce
:
const QKeySequence g_markerIncrease = QKeySequence(CTRL + Key_Plus);
This is how I used nativevirtualkey()
:
if ( event->nativeVirtualKey() == 187 ) //virtualkeycode for Non numeric PLUS
{
qDebug() << "message";
}
Edit 1: 187 is the integer value of VirtualKey hex value in VK List as per suggestion in Qt centre forum