Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Keyboard capture : modifiers & keypad: (2 Items)
   
Keyboard capture : modifiers & keypad  
Hello,

I'm trying to capture keyboards events : it seems that it is impossible to get Alt or AltGr modifiers.

At the same time : NumLock seems to have no effect, if I press a keypad key I always get the non-numeric key ( for 
example key 9 gives page up).

Is it a problem of keyboard driver ? 
I use a usb keyboard on my sabrelite board.
Re: Keyboard capture : modifiers & keypad  
I've just made a simple test app based on a widget template project which filters all key events and also processes all 
events in the usual way. I've tested it on imx6 sabrelite with the apps and media sample OS image, a US usb keyboard 
attached and with Qt 5.3.1. All keys incl. modifies are reported as expected. 

Not sure if it is about a different keyboard layout or a driver... This escapes my QNX knowledge, but this is not a 
generic issue in Qt on QNX, unless it is a broken Qt build

{code}
#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    installEventFilter(this);
}

bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
    if (event->type() == QEvent::KeyPress) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        qDebug("Filered a key press %d", keyEvent->key());
        return false; // keep in the loop for further processing
    } else {
        // standard event processing
        return QObject::eventFilter(obj, event);
    }
}

void MainWindow::keyPressEvent(QKeyEvent *event)
{
    qDebug("Key event received:");
    qDebug() << "\tno modifier pressed: " << event->modifiers().testFlag(Qt::NoModifier);
    qDebug() << "\tkey: " << event->key();
}

MainWindow::~MainWindow()
{
    delete ui;
}
{code}