I try to intercept keyboard events using qwsEventFilter. First of all I must mention that currently I use Qt-creator on X86 Ubuntu and may be this causes problems..
What I did:
myapp.h
{
public:
MyApp
(int &argc,
char **argv
) : QApplication( argc, argv
) {};
};
class MyApp : public QApplication
{
public:
MyApp(int &argc, char **argv ) : QApplication( argc, argv ) {};
bool qwsEventFilter(QWSEvent * event);
};
To copy to clipboard, switch view to plain text mode
myapp.cpp
#include "myapp.h"
{
if(e
->type
== QEvent::KeyPress) { qDebug("pressed");
}
else if (e
->type
== QEvent::KeyRelease ) { qDebug("released");
}
return false;
}
#include "myapp.h"
bool MyApp::qwsEventFilter(QWSEvent *e)
{
if(e->type == QEvent::KeyPress) {
qDebug("pressed");
}
else if (e->type == QEvent::KeyRelease ) {
qDebug("released");
}
return false;
}
To copy to clipboard, switch view to plain text mode
main.c
#include <QtGui/QApplication>
#include "myapp.h"
#include "qt-linphone.h"
int main(int argc, char *argv[])
{
MyApp a(argc, argv);
Widget w;
w.show();
return a.exec();
}
#include <QtGui/QApplication>
#include "myapp.h"
#include "qt-linphone.h"
int main(int argc, char *argv[])
{
MyApp a(argc, argv);
Widget w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
if I run the application with -qws and then hit any button on a keyboard I don't see "pressed"/"released". What is wrong with my code? May be Qt creator can handle QWS related code? Anyway I tried to use x11EventFIlter and it didn't even compile because of absence of XEvent definition..
Bookmarks