1

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

  • 1
    @Azeem thanks for the edit – porchezhiyan Jul 18 '18 at 11:51
  • You are welcome! What is `187`? Did you try this with latest Qt versions? – Azeem Jul 18 '18 at 11:59
  • 1
    Take a look at this: http://doc.qt.io/qt-5/qkeysequence.html#keyboard-layout-issues – Azeem Jul 18 '18 at 12:05
  • 1
    I tried in Qt 5.5.0 and 5.5.1 and 5.11.1 but still the issue persisted. Regarding value 187 I added a edit.I Checked the layout issues ,there must be someway to solve this issue (Note: in Qt creator shortcut for 5.5.1 CTRL + PLUS worked fine for increasing font size in german keyboard.). Now I'm working on finding the solution with QKeyEvent(). Though knowing how to handle this issue in QkeySequence would help in future avoid the focus issues in qKeyEvent – porchezhiyan Jul 18 '18 at 12:54
  • Right. You should report a bug also to get a quick response from Qt team. – Azeem Jul 19 '18 at 04:17

0 Answers0