View Full Version : Keyboard layout

19th October 2009, 15:15

I am running a Qt application on a system using an older version of the XServer. I cannot configure the keyboard layout on X, so I wonder if it is possible to change the keyboard layout internally in the Qt application.

For example, when I press ';' on the keyboard, I want to capture the keyboard event, convert the keypress from ';' to a Turkish character and provide the new keyboard event to the application.

Is it possible to do so or do I have to configure the XServer somehow to change the keyboard layout ?


20th October 2009, 01:15
You can install an event filter on the application object so that you capture all events before they reach their destinations. Unfortunately after intercepting a key press event you will have to generate and deliver (probably using QCoreApplication::sendEvent()) the new key event yourself.

20th October 2009, 08:31
our old code will help u a lot

bool GraphView:: eventFilter(QObject *ob, QEvent *e)
if(e->type() == QEvent::KeyPress){
printf("is it coming inside event..\n");
const QKeyEvent *ke = static_cast<QKeyEvent *>(e);
if(ke->key()== Qt::Key_A){ //check enum Qt::Key
//do your modifications here
printf("A button clicked..\n");
return true;
return QWidget::eventFilter(ob, e);