Project

General

Profile

RE: MityDSP-L138F - Qt application not seeing USB keyboard ยป main.cpp

Mathew Jones, 01/19/2016 10:56 AM

 
1
#include "mainwindow.h"
2
#include <QApplication>
3

    
4
#include <QKeyEvent>
5
#include <QDebug>
6

    
7
class myEventFilter: public QObject
8
{
9
public:
10
    myEventFilter():QObject()  {}
11

    
12
    ~myEventFilter() {}
13

    
14
    bool eventFilter(QObject* object,QEvent* event)
15
    {
16
        if(event->type() == QEvent::KeyPress)
17
        {
18
            QKeyEvent* pKeyEvent = static_cast<QKeyEvent *>(event);
19
            qDebug() << "Filtered KeyPress Event.." << pKeyEvent->key() << ", " << QChar(pKeyEvent->key());
20
            return true;
21
        }
22
        else
23
        {
24
            return QObject::eventFilter(object,event);
25
        }
26
    }
27
};
28

    
29
int main(int argc, char *argv[])
30
{
31
    QApplication a(argc, argv);
32
    MainWindow w;
33
    w.show();
34

    
35
    a.installEventFilter(new myEventFilter());
36

    
37
    return a.exec();
38
}
    (1-1/1)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)